c - Handling Functions and Pointers -
i'm not c programmer need simple poc 1 of our applications can extended c. i've got code compiling passing data straight through module , idea pass out reverse of character string passed in prove code has done data.
i have code pass each input straight output:
infa_ctsetdata(outputgroupports[i], infa_ctgetdatastringm(inputgroupports[i]));
the infa_ctgetdatastringm
function defined as:
char* infa_ctgetdatastringm(infa_ct_inputport_handle datahandle);
i have found function reverse string here
char *mystrrev(char *s) { char *start = s, *t = strchr(s, '\0'); /* point end of string */ /* * swap values @ beginning (pointed 's') , end * (pointed 't'); 's' , 't' meet in middle. */ ( --t/* skip terminating null character */; s < t; ++s, --t ) { /* run-of-the-mill swap here. */ char temp = *s; *s = *t; *t = temp; } return start; }
what i'm failing pass result of call infa_ctgetdatastringm
through mystrrev
, on infa_ctsetdata
.
infa_ctsetdata(outputgroupports[i], mystrrev(infa_ctgetdatastringm(inputgroupports[i])));
produces these errors @ compilation
p_reverse.c:155: error: conflicting types 'mystrrev' p_reverse.c:145: error: previous implicit declaration of 'mystrrev' here
years if visual basic , c# have made life easy - can 1 me code working? i've blindly tried adding *
, &
different compiler errors - , i'm stumped.
p_reverse.c:155: error: conflicting types 'mystrrev' p_reverse.c:145: error: previous implicit declaration of 'mystrrev' here
implicit declaration real antifeature left on days of yore. can enable warnings/errors (or c99 mode) prevent hurting you.
on line 145, have call mystrrev
, compiler has presumed declared int mystrrev(int)
. later, on line 155, define char *mystrrev(char *)
, conflicts "original" presumed int mystrrev(int)
.
add declaration of function before anywhere it's used (towards top of file) so:
char *mystrrev(char *val);
Comments
Post a Comment