| ehe wrote: |
|---|
| What would you do different and why? |
Since this is a Windows program, instead of using
system(), I would suggest using
ExitWindowsEx from
windows.h. See https://msdn.microsoft.com/en-us/library/windows/desktop/aa376868(v=vs.85).aspx .
Some reasons as to why not to use
system(): http://www.cplusplus.com/forum/articles/11153/ .
| ehe wrote: |
|---|
| And what does it matter if i have [100] or [50] after char buffer? |
char buffer [100]; means that buffer can safely hold 100
chars while
char buffer [50]; means that buffer can only safely hold 50
chars. It matters because you may have buffer overflow if you do not specify a buffer large enough, which can ruin program functionality/output silently. So why not specify a fail-safe buffer length like 10000000...? Because then your program will take up the unneeded memory of 10000000...
chars or whatever type you specified. It is important to manage your memory, especially in environments where available memory amounts are small like those of embedded/peripheral devices.