+ 2

Invalid suffix literal error!

#include <iostream> using namespace std; int main() { cout << "Hello world! \"<< "I love programming!"; return 0; } The above code compilation throws an error - "invalid suffix literal" what does that indicate?

3rd Mar 2018, 11:40 AM
Sreenidhi
Sreenidhi - avatar
4 Respuestas
+ 9
because you use \" and that means that " will be considered as " character and not enclosing string character so you didn't close string then
3rd Mar 2018, 11:42 AM
Vukan
Vukan - avatar
+ 5
\ " i.e. A space between \ and " escapes the whitespace and not the ". Hence, there is no error.
3rd Mar 2018, 11:50 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
However, "Hello World! \ " doesn't throw an error. \ followed by a space and then " works fine. Error occurs only when there is no space.
3rd Mar 2018, 11:42 AM
Sreenidhi
Sreenidhi - avatar
0
thanks guys!
3rd Mar 2018, 3:27 PM
Sreenidhi
Sreenidhi - avatar