Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More confusion

Status
Not open for further replies.

Netwrkengeer

IS-IT--Management
Apr 4, 2001
184
US
I'm new to programming, and trying to leanr it on my own, and I'm a little confused with syntax and how it differs between functions, variables, etc., and also how to interpret how to use a function from white papers, like MSVC++ on MSDN you can lookup and add functions to your programs by Downloading a Header file, and MSDN will give you a the syntax to use, I don't know how to use it.

So what I'd like to do is put 2 pieces of code below, the first one is code from a book I'm reading and the second one is a function from MSDN. If it is not too much trouble can you comment the first code at each line and tell me why each line is important and what it does.
And the second part, could you show me how to read the syntax and give me a sample code to use the command in. I hope this is not too much work.

Thanks


A. This is supposed to be a simple multiplication program, I will put in line numbers

1. #include <iostream.h>
2. #include <conio.h>
3. #pragma hdrstop
4.
5. int multiply(int, int);
6. void showResult(int);
7.
8. int main(int argc, char **argv)
9. {
10. int x, y, results;
11. cout << end1 << &quot;Enter the first value: &quot;;
12. cin >> x;
13. cout << &quot;Enter second value: &quot;;
14. cin >> y;
15. result = multiply(x, y);
16. showresult(result);
17. cout << end1 << end1 << &quot;Press any key to continue...&quot;;
18. getch();
19. return 0;
20. }
21.
22. int multiply(int x, int y)
23. {
24. return x * y;
25. }
26.
27. void showresults(int res)
28. {
29. cout << &quot;The result is: &quot; << res <<end1;
30. }


B. This is directly of of the Microsoft website. I don't get how you use it. but I do have the NPPTypes.h file.

The NETWORKINFO structure describes a NIC.

typedef struct _NETWORKINFO { BYTE PermanentAddr[6]; BYTE CurrentAddr[6]; ADDRESS OtherAddress; DWORD LinkSpeed; DWORD MacType; DWORD MaxFrameSize; DWORD Flags; DWORD TimestampScaleFactor; BYTE NodeName[32]; BOOL PModeSupported; BYTE Comment[ADAPTER_COMMENT_LENGTH];
} NETWORKINFO, *LPNETWORKINFO;


Members

PermanentAddr
Permanent MAC address.

CurrentAddr
Current MAC address.

OtherAddress
Other address that support this (for example, IP, IPX).

LinkSpeed
Link speed, measured in Mbps.

MacType
Media type.

MaxFrameSize
Maximum frame size allowed.

Flags
Informational flags.

TimestampScaleFactor
For example, a value of 1 indicates 1/1 ms, 10 indicates 1/10 ms, 100 indicates 1/100 ms, and so on.

NodeName
Name of remote workstation.

PModeSupported
NIC P-mode support indicator.

Comment

Adapter comment field.

Requirements
Windows NT/2000/XP: Included in Windows NT 4.0 and later.

Header: Declared in NPPTypes.h.
 
Your right! It is a lot of work.

My question to you; from pedagogical(of or pertaining to learning or education :) ) standpoint is; what do the lines mean to you?

It seems like you are grasping at straws in the dark.

Can you define a function? A variable? A procedure? A string? It's hard for me to tell by your post and I'm afraid if I attempt to answer these questions they will only serve to create more - without you first doing the needed work on your own.

If you answer my question then I'll answer yours.(We all must do the hard bits so when we get bit we know where to bite :))

May I suggest you get a good programming book. Also, although not impossible, C/C++/MFC are not necessarily the easiest tools to start learning from(I am not recommending you don't try - by all means do), it's just that, I'd try other languages as well so you don't get so frustrated.

Darrell
 
You are correct, I can not accurately define a procedure or a string

But I do know a function is a bunch of operation grouped together that perform a defined task and a Variable is used to store info in memory.

and I think a procedure another name for a functions, or just a group of functions.

But I have no Idea what a string is.

As for books, I've tried to Read some books, but keep getting lost, for example, I'm reading (sams, teach your self visual C++ in 21 days) and I'm confused. so I thought defining why this simple code is written and what it means I maybe able to understand what I'm reading, as for the data structure from MSDN, I was doing research on how to get info on analyzing a network connection (I figured if I had a goal, I could learn by doing) this is what I found.

So if you could point me in a direction that would be really helpful, or maybe you can give me some small lessons to get the basics rolling, that would be cool to.

The funny thing is at this point, I'm not sure what I don't know. or what is slowing me down.
 
Reading books on C++, VC++ or whatelse you want won't do it.
Getting some code and trying to learn programming fundamentals won't do it as well.
What you have to do is practice those things from the books
on or PC.
I myself don't like very much those &quot;Teach in 7, 14 or 21 days&quot; - books.
I recommend that you get yourself Kernighan & Richies C++
and start with the simple things.
As for the moment with what you have posted forget B.
Start with A, and if you want to (and have the time to) go
through the code line by line and post your questions on
the statements you don't understand.
Try to compile the code and try to run the program.
But remember that it shouldn't be done that way
You won't read The New York Times and then ask what does
the word &quot;president&quot; mean.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top