|
From: Iuri K. <IK...@am...> - 2001-07-17 15:51:41
|
I can't find any tutorial about Malloc for strings.
I want to read a string (line) from a file named 'script'. Each line has one
string with diferent size.
The MAX string will have 30 chars.
I know it is very simple, but I can't find the solution.
Thanks,
Iuri
---------
char linha1 [30];
char *linha1_ptr = linha1;
linha1_ptr = malloc (30);
...
fgets (linha1_ptr , sizeof(linha1_ptr) , script);
printf(linha1_ptr,"\n");
fputs(linha1_ptr, tudo);
write(sockfd, linha1_ptr, sizeof(linha1_ptr));
write(sockfd, "\n\r",2);
------------
|