Search This Blog

Saturday, March 10, 2012

removing the null terminator at the end of string

removing the null terminator at the end of string

Hi There,

Don't worry I found the way to do it. See below:

while (!feof(fp)) {
fgets(line,LINE_BUF,fp);
count++;
i=strlen(line);
strncat(string1,line,i-1);
printf( " %s %d %d\n ", string1, strlen(string1) ,count );
strcpy(string1,BLANK);

The reason why I needed to remove the null terminator is I need to load this data into a linklist. I don't much about C so a little help would be handy. Thanks. 
 
 
 
====================================================
 
 strncat(char str1, char str2, strlen(str2)-1)  will give string str1 with no terminator at the end of string

No comments:

Post a Comment

Thank you