| | |
Doubts in C
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2005
Posts: 15
Reputation:
Solved Threads: 0
Plz answer my these C doubts-
Q. 1- If i have 3 source files and i declare a static variable in the source file s2.c then which statement is true:-
That static variable is created when the program starts executing and is destroyed when the whole program finishes executing.
OR
That static variable is created when the source file s2.c starts executing and is destroyed when the file s2.c finishes executing.
(I dont want to know abt the scope of the static variable)
Q. 2- Header contains the declarations of functions & variables and in C it is not necessary(even though its safer) to give a prototype of a function before its use in the program. So does it mean that if we dont include a header file which declares a function X(), even then we can use that function(bcoz the header file contains only the prototype of the function, which is not necessary in C).
Q. 3- What do the .obj and .lib files contain?
Q. 1- If i have 3 source files and i declare a static variable in the source file s2.c then which statement is true:-
That static variable is created when the program starts executing and is destroyed when the whole program finishes executing.
OR
That static variable is created when the source file s2.c starts executing and is destroyed when the file s2.c finishes executing.
(I dont want to know abt the scope of the static variable)
Q. 2- Header contains the declarations of functions & variables and in C it is not necessary(even though its safer) to give a prototype of a function before its use in the program. So does it mean that if we dont include a header file which declares a function X(), even then we can use that function(bcoz the header file contains only the prototype of the function, which is not necessary in C).
Q. 3- What do the .obj and .lib files contain?
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).
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).
/pern.*/i
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
>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.
"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.
I'm here to prove you wrong.
•
•
•
•
Plz answer my these C doubts-
Q. 1- If i have 3 source files and i declare a static variable in the source file s2.c then which statement is true:-
That static variable is created when the program starts executing and is destroyed when the whole program finishes executing.
OR
That static variable is created when the source file s2.c starts executing and is destroyed when the file s2.c finishes executing.
(I dont want to know abt the scope of the static variable)
http://www.daniweb.com/techtalkforum...s/solution.gifA)second statement is true
Q. 2- Header contains the declarations of functions & variables and in C it is not necessary(even though its safer) to give a prototype of a function before its use in the program. So does it mean that if we dont include a header file which declares a function X(), even then we can use that function(bcoz the header file contains only the prototype of the function, which is not necessary in C).
http://www.daniweb.com/techtalkforum...s/solution.gifA)function prototype is necessary only in C++ as its one of the syntax that u should give function definion b4 u use it in main() as function prototype.
In C its not needed 2 declare the prototype of a function.
The answer 4 ur question is yes if u r working with a c compiler.
Q. 3- What do the .obj and .lib files contain?
.obj refer to the files related to have object code contained in them.
.lib refer to files related to library functions.
KVPRAJ
•
•
•
•
>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.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- c doubts (C++)
- python extending with c(doubts) (Python)
- Junior Developer have some doubts in CF_SQL_NUMERIC (ColdFusion)
- Doubts in i/o and others in 'C' (C++)
- Few doubts in the Java Environment (Java)
- Doubts about spyware fixer programs (Viruses, Spyware and other Nasties)
Other Threads in the C++ Forum
- Previous Thread: shri code
- Next Thread: In need of clarification
| Thread Tools | Search this Thread |
api array based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






