Thread: 2 Quick questions

  1. #1
    Registered User
    Join Date
    Sep 2010
    Location
    Boston, MA
    Posts
    97

    2 Quick questions

    Just finished my first C course!! And have 2 little things i was wondering if someone could clarify.

    1. Is a string defined as a nulled char array?

    2. What's the difference for a main to be defined as "int main(void)" rather than "void main ()"?

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    1) If you mean "is a string a character array terminated by \0" then the answer is yes.

    2) Cprogramming.com FAQ > main() / void main() / int main() / int main(void) / int main(int argc, char *argv[])
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  3. #3
    Registered User
    Join Date
    Sep 2010
    Location
    Boston, MA
    Posts
    97
    thanks that link was great

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Two quick questions
    By Neolitic in forum C++ Programming
    Replies: 2
    Last Post: 03-27-2008, 10:54 AM
  2. Two quick questions about open file dialog boxes
    By PJYelton in forum Windows Programming
    Replies: 5
    Last Post: 04-05-2005, 08:49 AM
  3. Questions on basic Quick Sort
    By Weng in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2003, 10:06 AM
  4. A quick question(s)
    By EvBladeRunnervE in forum C++ Programming
    Replies: 3
    Last Post: 02-17-2003, 09:39 PM
  5. A few quick questions...
    By cpp4ever in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2001, 09:28 AM