|
|
strccpy
Hi,
I understand from the solaris man page that strccpy compress the c
escape sequence from the source and copy the string to target.
I wrote the following program to realize the same. But the output
seams to be same. Please let me know in what way can I realize the
output:
$> gcc temp.c -o temp -lgen
int main ()
{
const char *s1="Hello\nWorld";
char *s2 = (char *)malloc (30);
printf ("s1[%d] : %s\n", strlen(s1), s1);
s2 = strccpy (s2, s1);
printf ("s2[%d] : %s\n", strlen(s2), s2);
}
--
Dust
|
|
0
|
|
|
|
Reply
|
clcfans (4)
|
6/3/2010 4:42:06 AM |
|
In article <16621031-3fd9-417f-bfe3-f598b691141f@j12g2000pri.googlegroups.com>,
proxy foxy <clcfans@gmail.com> writes:
> Hi,
>
> I understand from the solaris man page that strccpy compress the c
> escape sequence from the source and copy the string to target.
> I wrote the following program to realize the same. But the output
> seams to be same. Please let me know in what way can I realize the
> output:
>
> $> gcc temp.c -o temp -lgen
>
> int main ()
> {
> const char *s1="Hello\nWorld";
> char *s2 = (char *)malloc (30);
> printf ("s1[%d] : %s\n", strlen(s1), s1);
> s2 = strccpy (s2, s1);
>
> printf ("s2[%d] : %s\n", strlen(s2), s2);
> }
The C-language escape sequences have already been interpreted (compressed)
by the compiler. You will need to double-up the backslash to get the string
defined with the two characters '\' and 'n' in it.
const char *s1="Hello\\nWorld";
--
Andrew Gabriel
[email address is not usable -- followup in the newsgroup]
|
|
0
|
|
|
|
Reply
|
andrew
|
6/3/2010 8:32:22 AM
|
|
|
1 Replies
223 Views
(page loaded in 0.037 seconds)
Similiar Articles: Matching parenthesis in files - comp.lang.awkI was stumbling over how to integrate the (13) into the actual `for` loop due to the `strcpy` as this misdirects the contents of the variable to some degree but I'll look ... Problem in porting from 32 bit to 64 bit application - comp.os.ms ...... szClass, "%s.%s.%s",g_szPrefix,szWindow, g_szSuffix); } else { strcpy_s(szClass,256,szStatic); } bool bval=FindMFCClass(szWindowTilte); if(bval) { strcpy ... When does a program receive SIGABRT - comp.unix.solaris... statID == NULL || statInfo == NULL) { cmnError (LOGGED_ERROR, "dt_find: Require appID, statID, statInfo all non-NULL"); return NULL; } strcpy ... Solaris 10: How can I get a date that is exactly 30 days back ...... date_format=(char *)malloc(strlen(argv[2])); > > date_format=(char *)malloc(strlen(argv[2])+1); date_format = malloc(strlen(argv[2])+1); > >> strcpy ... Spawn process: No such file or directory - comp.parallel.mpi ...... scanf("%d", &universe_size); } else universe_size = *universe_sizep; if (universe_size == 1) printf("No room to start workers"); strcpy(worker_program ... Incorrect IP header data in RAW Sockets - comp.unix.solaris ...... ip.ip_hl*4, 0 ); memcpy(lBuffer+sizeof(ip), &udphdr, sizeof(udphdr)); /* build the address */ memset( &from, 0 , sizeof(from)); //strcpy ... error C2375 - redefinition; different linkage - comp.lang.c ...error C2375: 'strcpy' : redefinition; different linkage ... You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question ... read() error - Bad Address - comp.unix.programmer... to point to space for 100 string pointers or is it supposed to point to a statically allocated string? Hint: mesg = "whatever"; is not the same as strcpy ... ntpd IPv6 support on Windows? - comp.protocols.time.ntpIf you send in a too-long szNodeName, then the strcpy() will overwrite lots of stack values. :-( Terje -- - <Terje.Mathisen@hda.hydro.com> "almost all programming can ... nptq -p slowness - comp.protocols.time.ntp... dstadr_refid = - stoa(&dstadr); + nntohost(&dstadr); } else if ((int)strlen(value) <= 4) { refid_string[0] = '.'; (void) strcpy(&refid ... strcpy - C++ Reference - cplusplus.com - The C++ Resources NetworkCopies the C string pointed by source into the array pointed by destination, including the terminating null character. To avoid overflows, the size of the array ... C string handling - Wikipedia, the free encyclopediaC string handling refers to a group of functions implementing operations on strings in the C standard library. Various operations, such as copying, concatenation ... 7/24/2012 9:28:54 AM
|
|
|
|
|
|
|
|
|