Primitive questions
Dear all,
I am having few questions regarding c (I am starting a new thread) as I do not want to mix those with me previous network programming questios, I posted here earlier. 1) I found that one can get information about basic c function from linux bash with man... Well I have to admit that I did not expect that. I thought that the man is only related to the bash linux only. Where it gets the information for the the c libraries. How it distingushes between c and bash commands? 2) I have found in my c document a text about macros. What is a macro? Is for example the sizeof myvariable a macro? Where these are declared? 3) IF i have a struct lets call it mystruct and then I do memset(&mystruct,0, sizeof mystruct) this will set to zeros all the variables inside of the struct, regardless what type of variables it includes. Is not that right? I would like ot thank you in advance for your help Regards Alex |
1. man has sections. see man man. In general you can ask for a manual of anything available on a linux.
2. macro: http://h30097.www3.hp.com/docs/base_...E/DOCU_077.HTM 3. right |
Quote:
|
define is general, you can do strange things with define, for example:
Code:
#define BUBBLE + with this you can force the compiler for stricter checks |
Quote:
#define int mytype # (the second # ends the define statement) and then use mytype to define a new data type mytype MyNewIntegerVariable What is the "extra" that typedef offers? Alex |
in case of a macro the preprocessor will evaluate it and therefore they will replace mytype with int, so the syntax checker will see int.
in case of typedef the preprocessor will leave it as is (because it is not a macro) and the syntax checker will be able to handle them as different types. so in case of macro (#define int mytype) void myfunc(int) and void myfunc(mytype) will be exactly the same, using typedef they will be incompatible, so you can distinguish them. the compiler will generate the same code anyway. |
Quote:
Code:
typedef int size_type; Kevin Barry |
All times are GMT -5. The time now is 11:03 PM. |