copying strings from 2d array into 1d array
Im having some trouble dealing with pointers in C.
My code loads in a large string of characters from a text file
1378251369.691375 84:1b:5e:a8:bf:7f 68:94:23:4b:e8:35 100
1378251374.195670 00:8e:f2:c0:13:cc 00:11:d9:20:aa:4e 397
1378251374.205047 00:8e:f2:c0:13:cc 00:11:d9:20:aa:4e 397
1378251374.551604 00:8e:f2:c0:13:cc 00:11:d9:20:aa:4e 157
1378251375.551618 84:1b:5e:a8:bf:7c cc:3a:61:df:4b:61 37
and then copies each line into an array (fullinfo[200][BUFSIZ]).
im then trying to asses the last two pieces of info and put them into
there own array e.g.
cut2line[0] = 68:94:23:4b:e8:35 100
cut2line[1] = 00:11:d9:20:aa:4e 397
to do this I have tried strcpy and memcpy
fullinfo[200][BUFSIZ];
char cutline[BUFSIZ];
char cut2line[BUFSIZ];
while( fgets(line, sizeof line, pi) != NULL) {
strcpy(fullinfo[infoline], line);
strcpy(cutline,fullinfo[infoline]);
memcpy(cut2line,*cutline[25],100);
printf("%s",cutline);
infoline ++;
}
both of which give either
invalid type of argument of unary '*' (have 'int')
or something involving wrong pointer types.
any help is appreciated.
Edit to clarrify: cutline contains the whole line fromthe input file which
is correct, but when i try to copy the second part of the line into its
own array i get the errors
No comments:
Post a Comment