Guest User

Untitled

a guest
Nov 23rd, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  1. struct one {
  2.     char a;
  3.     char b;
  4. };
  5.  
  6. struct two {
  7.     struct one c;
  8.     struct one d;
  9. };
  10.  
  11. void firstfunction(void *source, void *dest, int size)
  12. {
  13.     memcpy(dest,source,size)
  14. }
  15.  
  16. void secondfunction(struct two *onedata)
  17. {
  18.     struct two twodata;
  19.     firstfunction((void *)onedata->c,(void *)&twodata.c,2);
  20. }
  21.  
  22. void main()
  23. {
  24.     struct two onedata;
  25.     secondfunction(&onedata);
  26. }
  27.  
  28. gcc -g -O2    struct.c   -o struct
  29. struct.c: In function ‘secondfunction’:
  30. struct.c:19:2: error: cannot convert to a pointer type
  31.   firstfunction((void *)onedata->c,(void *)&twodata.c,2);
  32.   ^~~~~~~~~~~~~
  33. <builtin>: recipe for target 'struct' failed
  34. make: *** [struct] Error 1
Add Comment
Please, Sign In to add comment