c++ Pass quoted string as char array to a function -


so have function declared as:

void writefile (unsigned char *filename, unsigned char *data) 

if call function this:

writefile("f.txt", "test1"); 

is fine.

if second call this:

writefile("s.txt", "test2\nline"); 

the filename fine, data corrupted (the first 5 bytes messed up).

if third call this:

writefile("f.txt", "test3\r\nline"); 

the filename corrupted, , data has it's first 5 bytes messed up.

what going on?

i believe problem has using unsigned chars, when put code complains on compile it. may have unsigned char not being able use escape characters \n, can't sure.

intellisense: argument of type "const char *" incompatible parameter of type "unsigned char *" 

is compile error get.

when changed being regular char * parameters, worked fine.


Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

tags - Jquery Mixitup plugin help prevent handlers being destroyed -

c# - Delving into the world of XML (Windows Phone) Error I dont understand (The ' ' character, hexadecimal value 0x20, cannot be included in a name.) -