C,CPP Programming & Variable Naming Rules

2016 - 06 - 08

File Ambiguity

file: can be only filename, or full/relative path + filename.
location: full/relative path + filename.
filename: only name part, no path in string.
path: full/relative path w/o filename.

Common & Suggested Usages

//Common   → Suggested
chars       charSize
bytes       byteSize
int  * buf  int  *p_intListing
char * buf  char *p_inputFile
ifstream in ifstream inputStream

IF Statement Evaluation

if (c) is: if(c != 0)
if (!c) is : if (c == 0)
similar for boolean vars:
false === 0 and true === !0 === !false
However, all true evaluates to int 1:

cout << false  // 0
cout << true   // 1


var pre-fix

ph_ pointer of a variable in host RAM.
pd_ pointer of a variable in device mem.
pb_ pointer of a variable in block shared mem.

allocate & free mem

Everytime, when doing: cudaMalloc()
The following 2 actions are also required:
cudaMemcpy() and cudaFree().

Write a Comment