Hi,
I don't want to include '\0' when copying or concatinating strings. How to do that?
Printable View
Hi,
I don't want to include '\0' when copying or concatinating strings. How to do that?
Well, you could just ignore it or replace it with something else. Though without it, you'll be unable to perform any string operations on that string.
for this code I want to print all strings in one line :confused:Code:strcpy(tomv, "AB ");
strcat(tomv,l);
strcpy(tomv, " CD");
printf(tomv);
One line? What? Are you sure you aren't mixing up '\n' and '\0'? The null character has nothing to do with new lines.
You should also check your syntax as well because it's very wrong. Even on the printf().Code:char foo[13];
strcpy(foo, "Hello ");
strcat(foo, "World!");
printf("%s",foo);
/*
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Dev-Cpp>hworld
Hello World!
*/
Ohhh, :D . Sorry, I mean \nQuote:
Originally Posted by SlyMaelstrom
Sorry again :(
You'll have to either remove the '\n' before copying or use something like strncat() to only copy a certain number of character. If you use strncat() remember to manually terminate the finished string after the copy.