- C++: cin, cout, cerr, clog, fstream. C: printf, scanf, fscanf, FILE.
- From my experience, fopen and fscanf is better than fstream for file IO while cout, cerr, clog is better than printf for console messages.
- C++: vector. C: array. In C++, do not use array if size is dynamic or pointer is needed or multidimensional (anything other than int arr  or int matrix ). Use vector with built-in memory management.
- Both C++ and C are sequentially processed. It is recommended to separate utility functions in a separate .cpp but if necessary, add forward declaration and write functions after main().
- Don’t start from designing classes or structs. Start from “myutil.h” + “myutil.cpp” with disposable enclosed functions. Start object management after first prototype with all functions working independently.
- Don’t write exception handling in first prototype (except for critical errors). Just put a reminder in comment and write in next version.
- Older C compilers forced users to declare all of the variables in a function at the top of the function.
using namespace std;
int myfunc(int a, int b);
int myfunc(int a, int b)
File IO and Passing Pointer by Reference (C++)
void readFile(FILE* &FileStream)}
FileStream = fopen("filename.txt","r");
char data = 0;fclose(FILESTREAM);
fread(&data, sizeof(char), 1, FILESTREAM);
File IO and Passing Pointer by Reference (C)
void readFile(FILE** FileStream)
(*FileStream) = fopen("filename.txt","r");
char data = 0;fclose((*FILESTREAM));
fread(&data, sizeof(char), 1, (*FILESTREAM));