Error with quote inside quote.

Homework.
Creating a new alphabet.
if statements to check what certain chars and punctuations are, and reassignment to new values.

My backslash method for using quotes inside quotes isn't working, but I don't know what I'm doing wrong. Can anyone point it out please?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
char punk()
{
    char pun;
    for(int i='.'; i<='@'; i++){
        pun=i;
        
    if (pun == '.'){
    cout << "-+-+++- ";
    }
    if (pun == ','){
        cout << "-+-++-- ";
    }
    if (pun == ':'){
        cout << "-+++-+- ";
    }
    if(pun == '?'){
        cout << "-++++++ ";
    }
    if(pun == '/''){
        cout << "-+--+++ ";
    }
    if(pun == '_'){
        cout << "-+-++-+ ";
    }
    if(pun == '/'){
        cout << "-+-++++ ";
    }
    if(pun = "/""){
        cout << "-+-+-++ ";
    }
    if(pun == '@'){
        cout << "+------ ";
    }}
    return pun; 
1
2
3
// if(pun = "/"") {
if( pun == '"' ) { // use single quotes around a character.   
                   // ie. single quote, double quote, single quote 
That's a front slash.. Not a backslash. Change it and it should work. 😉
Look at this snippet:
1
2
    if(pun == '/''){
        cout << "-+--+++ "; 


You seem to be using the incorrect "escape" character. The escape character is '\'.

Next on line 28 you're trying to compare a char to a string, remember double quotes denote string constants. Also note if you don't need to escape a double quote within single quotes.

Hey,

Thanks everyone. I made it past that error.

1
2
3
4
5
6
char pun;
    for(char i='!'; i<='~'; i++){
        pun=i;
    
    
     //!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ 


Is that loop fine for assigning pun to every character in the list I have commented out?

Because when I call the function, it spits out waaaaaaay more barbed wire characters than I should have with my if statements in the previous post.
What exactly are you trying to accomplish?

Do you know the integral values of '!' and '~'? Do you know how many characters are between those two "numbers"?

Perhaps you should look up and study an ASCII chart.

Last edited on
Would it matter for my function? I checked to make sure the characters I needed to change were in the middle of those two ends.

It should only print out something if it matches my if statements right?
Topic archived. No new replies allowed.