String too long as a parameter?
-
Tuesday, February 28, 2012 6:43 PM
Hello,
I have a function taking in a char* which points to a long continous string. The problem is that I would like to type the string in twon different lines so I can see it all in one screen shot. Here's what I mean:
The following is okay,
RST_OpenRSet(pRstObj, eRSET_LOAD, 0, "IDX == 250 OR IDX == 230");
But if I want a long one like this:
RST_OpenRSet(pRstObj, eRSET_LOAD, 0, "IDX == 250 OR IDX == 230 XOR (IDX == 250 AND IDX != 5 OR IDX < 1) AND (IDX > 1 OR IDX == ALL) OR (IDX == 250 AND IDX < 251) XOR IDX == 0");
The latter doesn't fit in one line on my screen... in other words I have to scrool to the right to see the rest of the string. So I am trying to type the string on two lines like this:
RST_OpenRSet(pRstObj, eRSET_LOAD, 0, "IDX == 250 OR IDX == 230 XOR (IDX == 250 AND IDX != 5 OR IDX < 1) AND (IDX > 1 OR IDX == ALL) OR (IDX == 250 AND IDX < 251) eXOR IDX == 0");
However the 2nd line doesn't follow the string and is considered as other command statements. Is there a way to type a string on two different lines?
I also tried a similar example in VC++ 2010 and I got the following errors:
void f1(char* x){} int main(void) { f1("dsfgsd fasdfgsdf); }1>c:\_programming\_microchip_issues\simulated in vc++\examples\test\test\testgoran.c(71): error C2146: syntax error : missing ')' before identifier 'fasdfgsdf'1>c:\_programming\_microchip_issues\simulated in vc++\examples\test\test\testgoran.c(70): error C2001: newline in constant
any ideas would be greatful
r
- Edited by _roberto_ Tuesday, February 28, 2012 9:10 PM
All Replies
-
Tuesday, February 28, 2012 6:56 PM
Try this:
RST_OpenRSet(pRstObj, eRSET_LOAD, 0,
"IDX == 250 OR IDX == 230 "
"XOR (IDX == 250 AND IDX != 5 OR IDX < 1) "
"AND (IDX > 1 OR IDX == ALL) "
"OR (IDX == 250 AND IDX < 251) XOR IDX == 0" );
- Edited by Viorel_MVP Tuesday, February 28, 2012 6:57 PM
- Marked As Answer by Rob PanModerator Friday, March 02, 2012 6:10 AM
-
Tuesday, February 28, 2012 6:59 PM
Hi Viorel_
Ahh! this compiles... I have to check if it actually treats the two lines as one contnous string....
But thanks ... so far so good!
r
-
Tuesday, February 28, 2012 7:48 PM
Two adjacent string liters, separated only by whitespace (think blanks and newlines, not the funny '\' line continuation character) will be combined into a single literal by the compiler in one of the early compilation phases well before the statement or definition is used to generate code. More than two such literals are combined by following the above process repeatedly.- Marked As Answer by Rob PanModerator Friday, March 02, 2012 6:10 AM
-
Tuesday, February 28, 2012 8:12 PM
Hi guys,
Works like a charm!
Thanks guys
r

