i'm trying to copy a const char* string (call it stringA) to a char* string (stringB).
now lets say stringA is 20 characters long and i only want to copy 10 of those characters to stringB. Whats the best possible way to go about doing it?
i've tried using a for loop..
... but this only results in a segmentation core fault.
for (i=0; i < 10; i++)
stringB[i] = stringA[i];
stringB[i] = '\0';
then i tried using strncpy...
.. but this isnt giving me the results i want. its copying the whole stringA into stringB.
strncpy(stringB, stringA, 10);
what am i doing wrong? Any help would be great.