problem passing string to a function

My current problem is that I had something that compiled without a problem.
It worked with my old system perfectly.
I had a function shown partially here:
1
2
3
4
5
6
7
8
9
10
void traceP (char st2[100], int xtrSp = 1)
{
     // here it writes the string to a file
}

in my main program:
{ 
      traceP(“write this to a file”); // or whatever
}
I know this has something to do with pointers, but???
I am using the latest Embarcadero C++ and Windows 10.
Last edited on
Probably a problem with Unicode, some compilers haven't made the jump from ascii. Simply try retyping the string from scratch, including the quotation marks.
1
2
3
4
5
6
7
8
9
void traceP (char st2[100], int xtrSp = 1)
{
     // here it writes the string to a file
}

in my main program:
{ 
      traceP("Write this to a file"); // or whatever
}

See how line 8 has different highlighting?

Edit: Actually, it looks like the only Unicode is the quote marks themselves, but there is a possibility of Unicode for white space or non-printables (like zero-width characters) that would be hard to track down...
Last edited on
Your main program is passing a const char[] array - which couldn't be changed.

Your function prototype is allowing you (in principle) to change a char[] array. So that's not compatible.

Just stick const before the char[] in the function.
Thanks to "lastchance" it works. I guess when I upgraded to Windows 10 and the latest C, something looked at it a bit more critically.

I have a file of bunches of functions that I can pull out for whatever I need.
This was one of them.
Last edited on
Topic archived. No new replies allowed.