hi
i am trying to copy the returned value (not really the returnd pointer but what it points at) from function gets but its not working
and when i try to print it or print the str_infile before strcpy function , its not printed out !!
i added temp_buff before but made alot of problems so i removed it !
i need to store the lines from C_data file into array like this
char temp_buff [400] ;
temp_buff[0] = "first line "
temp_buff[1] = "2bd line "
temp_buff[3] = "3rd line "
and so on !
i tried
for (i = 0 ; i <sizeof (file_p)-1;i++ )
printf ("buff_lines \n " ,& temp_buff[i]) ;
or even
printf("buff\n " ,temp_buff);
sure in loop but when i do such thing i dont get output or i get error
why cant i do this
temp_buff = fgets(str_infile,70,infile );
or
temp_buff = str_infile ;
or even save the value returned from puts to the array ?
i need to use temp_buffer as seprate array after that
thank you :)
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
int i =0;
char str_infile[400];
char *file_p ; // file pointer to what fgets return
FILE *infile;
if((infile=fopen("C_data","r"))==NULL){
printf("\nUnable t open file C_data");
return -1 ;
}
while(fgets(str_infile,70,infile)!=NULL){
puts(str_infile );
printf(" \n " ,& str_infile) ; // this line doesnt work at all !
i ++;
file_p = fgets(str_infile,70,infile );
}
for (i = 0 ; i <sizeof (file_p)-1;i++ )
printf ("buff_lines \n " , file_p ) ;
fclose(infile);
return 0;
}