I have this code:
Code:
int readConfig(char *IP, int *p, char Myfile[]){
char dir[32];
char pto[32];
char c='a';
FILE *fp;
int i=0;

if((fp=fopen(Myfile,"r"))==NULL){
return -1;
}
while(c!=EOF && c!='\n'){
c=getc(fp);
if(c!=EOF && c!='\n'){
dir[i++]=c;

}
}

i=0;
c='a';

while(c!=EOF && c!='\n'){
c=getc(fp);
if(c!=EOF && c!='\n'){
pto[i++]=c;
}
}

*puerto=atoi(pto);
strcpy(IP, dir);
return 0;
}
and the file contains this information: 255.255.255.255
5555

Well, when I print the IP value, this is the result
IP: 255.255.255.255fhv���

How can I do for fix it??? I want that only print: IP: 255.255.255.255

Thanks!!!!

Last edited by shabbir; 16Nov2007 at 10:15.. Reason: Code block