Faq in C and C++ RRS feed

  • Question

  • 1.) What is the value of i in any of the following expressions:
    i = i++;
    i++ + ++i etc.

    Ans - This is undefined behaviour. Undefined does not mean compiler will generate an error. It just means that compiler is free to handle it any way. So you will see output but you can not rely on it. For more info on it, look at sequence points. Also refer the Standards.

    2.) What data type should the function main() return?

    Ans - According to the C and C++ standards the main() function should return 'int'. And if you are not passing command line arguments, use 'int main ( void )' in C and 'int main()' in C++. You can't even write this code 'main(){//...}' because use of implicit int is now illegal.

    3.) Where can I get the getch() / getche() function?
    What happened to clrscr() function?
    Why is the compiler saying it cannot find conio.h?

    Ans - Short answer - don't look for them.

    Long answer - These functions and headers are not part of the C or C++ standard. Nor is the functionality provided by these provided completely by any alternate functions / classes in the ISO C/C++ standards. Moreover, these are not even standard for any particular OS. They are Turbo C/C++ specific and we should not use these, nor should we use the older dos-based Turbo C/C++ for any programming we do in C/C++. Even if these functions continue to be available in the newer Turbo C/C++ which are more standards compliant, we should still completely shun their use. That's because these functions themselves are not standards compliant.

    4.) Where can I find 'XYZ' book?

    Ans - Before asking have you tried the following websites: .
    PSStick out tongueIRACY KILLS

    5.) I am new to learning C/C++, how should I proceed?

    Ans - Please start learning from the books prescribed above, with an intent to learn them properly. There's no quick fix to learning these languages. If you want to learn them for getting marks at your school/college. Then forget it, no one can help you.
    Wednesday, September 26, 2007 1:50 PM

All replies