Printing escape character

Posted by danutenshu on Stack Overflow See other posts from Stack Overflow or by danutenshu
Published on 2010-06-14T22:31:19Z Indexed on 2010/06/14 22:32 UTC
Read the original article Hit count: 174

Filed under:
|

When I am given "d""\"/""b", I need to print out the statement character for character. (d, b, a slash, a backslash, and 5 quotes) in C++. The only errors that show now are the lines if(i.at(j)="\\") and else if(i.at(j)="\""). Also, how should the outside double apostrophes be excluded?

 #include <iostream>
 #include <cstdlib>
 using namespace std;

 int main (int argc, const char* argv[] )
 {
     string i= argv[1];
     for (int j=0; j>=sizeof(i)-1; j++)
     {
         if(i.at(j)="\\")
         {
         cout << "\\";
         }
         else if(i.at(j)="\"")
         {
         cout << "\"";
         }
         else
         {
         cout << i.at(j);
         }
     }
     return 0;
 }

© Stack Overflow or respective owner

Related posts about c++

Related posts about escaped-characters