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

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -