Hi,
I don't want to include '\0' when copying or concatinating strings. How to do that?
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.
Sent from my iPadŽ
for this code I want to print all strings in one lineCode: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! */
Last edited by SlyMaelstrom; 07-03-2006 at 01:09 AM.
Sent from my iPadŽ
Ohhh, . Sorry, I mean \nOriginally 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.
If you understand what you're doing, you're not learning anything.