Hello i m suppose to make a function that fetch the strings according to num and it will stop when num is finished or it encounter , or ' ' or newline i made the function but its acting weird as if there is a \0 placed in
#include <stdio.h>
int ParseCh(char *N,char *Buffer,int n,char *STend) {
int i,x=0,end=0;
while(*N++) {
end++;
if(*N==',' || *N==' ' || *N=='\n'){
STend=N+1;
break;
}
else {
end=0;
STend='\0';
}
}
if(!end)//if end is 0 then there wasnt any new line etc we just do normal copy
for(i=n;Buffer[x]=N[i];i++,x++);
else//if we found end bigger than 0 then we will just copy till end
for(i=n;Buffer[x]=N[i] && Buffer[x]<end; i++,x++);
return x;
}
int main(void)
{
char Name[10];
char *End;//last string after the , or new lines etc if its initlised to 0 it means there was no , new lines or tab inside the string
ParseCh("NAME,M",Name,2,End);
printf("Name after being parsed %s and it ended at %s\n",Name,End);
return 0;
}