A question about strings...
This question is about C. Say I have a string 'test'. By looking at the chars we have { 't', 'e', 's', 't', '\0' }
Say I wanted to add a ': ' after it so that it becomes { 't', 'e', 's', 't', ':', ' ' } I use the following code to implement this. Code:
char str[16] = "test"; Code:
printf("%s", str); Code:
printf("%s\n", str); Code:
write(STDOUT_FILENO, str, sizeof(str)); |
Quote:
Code:
printf("%s\n", str); Code:
printf("%s", str); Code:
strncat(str, ": ", sizeof(str)); |
Thanks that explains it.
|
All times are GMT -5. The time now is 09:54 PM. |