Help: Strange Code Behavior

2 views
Skip to first unread message

Kai Baker

unread,
Feb 3, 2017, 2:57:37 PM2/3/17
to collexion
I'm experimenting with embedding C code in C++ as a wrapper in order to call execvp(). I pass two C strings to my C wrapper function. One is a const char* and the other is a char*. For some reason, the const char* passes and replicates the second element in the first when passing to the C function. However, that doesn't happen with the char*. I'm attaching a pastebin link for the code. You will be able to see what is going in better detail there.

Can anyone test this for me and see if you get the same result? I'm using gcc 6.2.1 to compile.
Kai

http://pastebin.com/EgYhU7eh

--

Kai Baker

unread,
Feb 3, 2017, 2:58:54 PM2/3/17
to collexion
This is the output that I get, which is different than what I was getting last night on a different computer. I wonder if it might be the gcc version I'm using.

s ls
s -l
cargv[0]: -l
cargv[1]: -l
t[0]: ls
t[1]: -l
cargsv -l
cargsv -l
forking

--

ben jeffries

unread,
Feb 3, 2017, 4:59:03 PM2/3/17
to coll...@googlegroups.com
can you explain, in normal language, the method signature you are trying to  call there?  I suspect there is an issue with the pointers in your method declaration.



--
You received this message because you are subscribed to the Google Groups "Collexion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to collexion+unsubscribe@googlegroups.com.
To post to this group, send email to coll...@googlegroups.com.
Visit this group at https://groups.google.com/group/collexion.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages