Wednesday, April 11, 2012

Skip and copy Function assistance

New programmer here. I need some help. So basically what im trying to do here is to copy certain parts of 1 string stored in an array into 3 different arrays by ignoring the "," in the string. I'll show you the code to be more clear.



#include<stdio.h>
#include<string.h>

main()
{
char temp[50];
char temp1[50],temp2[50],temp3[50];
int i,m;
strcpy(temp,"abc,123,rio");
for(i=0;i<strlen(temp);i++)
{
//printf("%c\n",temp[i]);
if (temp[i]==',')
temp[i]=='';
else
temp1[i]=temp[i];
}
printf("%s\n",temp1);
return 0;
}


Now the problem comes in at the part where it says "temp[i]==''"
I know that line is wrong. But i need some help there. I want to be able to skip the "," and move on to copy 123 in temp2 and rio in temp 3. So far i was only able to copy abc into temp1. I don't know exactly how to "Skip and copy" the rest. Please help fast ! :]





No comments:

Post a Comment