hi guys,
I have a simple question and I am new to c, Would appreciate any advise I could get.
Here's the doubt.
main()
{
char a[10],*a1,b[10],*b1;
a1=&a[0];
b1=&b[0];
int x=0;
for (x=0;x<=1-;x++0)
{
*a1++=*b1++;
}
}
Basically if I had a string in b[10] it would get copied to a 10 using the pointers. ( Dunt want to use strcopy as i could have a \0 ) The above method works..
Now if I want to do the same thing but into an array of structures:
struct temp
{
char a[10];
}
main()
{
char b[10],*b1,*k,k1[10];
struct temp m,*n;
n=&m;
b1= &b[0];
b1= "hellohello" ;
int x=0;
for(x=0;x<=9;x++)
{
(*n->a)++ = *b1++;
}
}
This gives me an error.
What I want to do, is copy data from an array I have into an array inside a structure using the pointer method though and not using strcpy. Any suggestions ?