Q1: Alternative 1
Q2: If the function X returns an integer, uses standard calling convention (and possibly is not dynamically linked, I'm not sure about the actual meaning of __declarespec(import)).
Q3: .obj is most oftenly compiled code, all functions and variables from a compiled source file. .lib I think contains either multiple such object files in a kind of archive, or link information for dynamic linkage (thought I'm not quite sure of this since it mostly just work for me).
perniciosus
Junior Poster in Training
78 posts since Nov 2005
Reputation Points: 29
Solved Threads: 4
>Plz answer my these C doubts-
"Doubt" is sometimes synonymous with "question", but not in this case. It's very common to ignorantly use doubt in place of question, and it's usually wrong. What you have a C questions, not C doubts.
>I dont want to know abt the scope of the static variable
Obviously, since your question has nothing to do with scope and everything to do with storage duration. There's no need to qualify your question as such because if someone starts talking about scope, you know that they're not qualified to answer it correctly. :)
>in C it is not necessary(even though its safer) to give a
>prototype of a function before its use in the program.
Wrong on two counts. First, the latest C standard removed that dangerous feature. Second, even in C89, the implicit function declaration doesn't always work depending on the arguments and return value of the function in question.
>What do the .obj and .lib files contain?
It depends heavily on the compiler and linker in question. The generic answer is that object files contain object code, which is the primary output of the compiler. The linker then uses the object code to piece together an executable file. Library files are basically independent collections of object code and links.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>Plz answer my these C doubts-
"Doubt" is sometimes synonymous with "question", but not in this case. It's very common to ignorantly use doubt in place of question, and it's usually wrong. What you have a C questions, not C doubts.
I think this is something taught in India. Theonly posters that have 'doubts' seem to be from there...
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Hi first you need to study operator precedence well. Here you are using ++ operator post fix and prefix. ++ directly charge the value in variable address.
post fix (a++)- print first and increment
perfix (++a)- increment first and print the value
[CODE][
printf("%a%a%a", a, ++a, a++);
1 //and then increment a = 2;
printf("%a%a%a", a, ++a, a++);
3 1 //its prefix so increment a = 3 an print
printf("%a%a%a", a, ++a, a++);
3 3 1
/CODE]
Firstyou need to study side effects and sequence points. The snippet exhibits undefined behavior, which means that the output can be anything at all. Further, the output isn't even required to be consistent. You can run the program twice and completely different results should be expected with undefined behavior.
This thread has become a wealth of bad examples...
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401