|
|
back to boardShow all messages Hide all messagesOn my dev-c++ (gcc) and on the old Timus compiler, they accept such code: char a[]="xxx...xxx"; (there are up to 200000 'x') But after lots of WA1's I tried to run it on VC2008, it won't compile! It said that sth like "string is to long" (Sorry my VC isn't in English so I can't tell exactly) So to solve this problem now, you have to think of a more complicated way... And it took me much effort to escape that terrible WA1.. Exactly! In MSVC2008 we have the following restrictions on strings in C++: Length of one string unit must not be more than 65535 symbols (with ending \0 it is 65536). If you have greater string, you must devide it into several sub-strings, like I did in my solution: const char* psz[] = { "string one", "string two", ... }; And you cant write in one line more than ~2000 charecters in your source file, you have to put newline after each 2000 chars chunk, or compilation error will occure. Yeah, thx, but eventually I split it into array of char[1000] and it's all right to write the whole array on a single line. I think you are wrong. I've submitted my old solution, which has "unsigned char s[]="..." written in one line, and got AC again. The only thing I have is my own experience with MS C++ 2008 compiler. Maybe in VS C++ 2010 (which is currently used on Timus) they took off that restriction. in vc on timus limit ~16000 symbols Edited by author 29.06.2011 18:52 Another gotcha for C++ programmers: The line terminator in the input is "\r\n", so if you read input byte-by-byte, you will see both chars, but if you try to output "\r\n" via std::cout, you will get "\r\r\n" in the output. My solution was to just ignore \r in the input. * Be careful with percent signs using printf function: printf( "...if(c%3==0)..." ); // wrong!!! but sometimes it works printf( "...if(c%%3==0)..." ); // right * It isn't necessary but if you don't want to take care about CR LF characters, you can use this code: #include <io.h> #include <fcntl.h> _setmode(_fileno(stdin),_O_BINARY); _setmode(_fileno(stdout),_O_BINARY); * Don't use these characters: " ? \ Edited by author 03.11.2010 07:54 |
|
|