Hello everyone,
The code below is supposed to split an IPv4 address into 4 segments, {"192","168","1","1"}, and concatenate it together again with the last value (in this case "1") being iterated through using the for() loop.
The errors I'm receiving when compiling (using gcc) are:
1 2 3 4 5 6 7 8 9 10 11 12 13
test.c: In function ‘main’:
test.c:104:3: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [enabled by default]
In file included from test.c:3:0:
/usr/include/string.h:128:14: note: expected ‘constchar * __restrict__’ but argument is of type ‘unsignedchar’
test.c:105:3: warning: passing argument 2 of ‘strcat’ makes pointer from integer without a cast [enabled by default]
In file included from test.c:3:0:
/usr/include/string.h:136:14: note: expected ‘constchar * __restrict__’ but argument is of type ‘unsignedchar’
test.c:106:3: warning: passing argument 2 of ‘strcat’ makes pointer from integer without a cast [enabled by default]
In file included from test.c:3:0:
/usr/include/string.h:136:14: note: expected ‘constchar * __restrict__’ but argument is of type ‘unsignedchar’
test.c:107:3: warning: passing argument 2 of ‘strcat’ makes pointer from integer without a cast [enabled by default]
In file included from test.c:3:0:
/usr/include/string.h:136:14: note: expected ‘constchar * __restrict__’ but argument is of type ‘unsignedchar’
I've tried googling but no luck.
TL;DR: How do I strcpy an array element to a string?
Problem is that strcpy and strcat works only on strings (null terminated char arrays). If you want to convert the integer values back to strings you can use something like sprintf.