Why do I get always 4 for strlen(buf) ?
Code:int main() { int i = 1; char * buf ; while(i<11) { buf = new char[i++]; strcat(buf, "a"); cout << strlen(buf) <<"\n"; } delete [] buf; return 0; }
Why do I get always 4 for strlen(buf) ?
Code:int main() { int i = 1; char * buf ; while(i<11) { buf = new char[i++]; strcat(buf, "a"); cout << strlen(buf) <<"\n"; } delete [] buf; return 0; }
Using Windows 10 with Code Blocks and MingW.