ConsoleTom
Member
Hii !
Let's say i have a string
char strA[10];
The string contains "abcdef" but i need only "abc". Is it enough to terminate the string at the needed position ?
strA[4] = '\0'
Or can i use
strncpy (strA,strA,3);
or must i use a temp-variable
strcpy (strB, strA);
strncpy (strA,strB,3);
Tell me, what is the best solution.
Tobias
PS. Don't say strcpy(strA,"abc"); !!!!!
Let's say i have a string
char strA[10];
The string contains "abcdef" but i need only "abc". Is it enough to terminate the string at the needed position ?
strA[4] = '\0'
Or can i use
strncpy (strA,strA,3);
or must i use a temp-variable
strcpy (strB, strA);
strncpy (strA,strB,3);
Tell me, what is the best solution.
Tobias
PS. Don't say strcpy(strA,"abc"); !!!!!