need help on using toupper!

From: fighterman (fighterman_at_u.net)
Date: 03/27/04


Date: Fri, 26 Mar 2004 21:09:46 -0600

why the output only display 1 letter insteed of 1 word after I uppercase
it.

#include<iostream>
#include<fstream>
#include<cctype>
#include<string>

using namespace std;

int main()
{
        
        ifstream in; //input file
        string s;
        
        //open in file
        in.open("input.txt");

        //check to see whether the in file is existing
        if (!in)
        {
                cout<<"Can't not read the file !"<<endl;
                in.close();
                return -1;
        }

        getline(in,s,'\0');
        cout<<s;
        
        int len=s.length();
        char *cs= new char [len+1];
        s.copy(cs, len ,0);
    cs[len]='\0';

        char *tokenptr= strtok(cs, " ");
    while(tokenptr != NULL)
        {
                
                cout<<(char)toupper(*tokenptr)<<endl;
                tokenptr = strtok (NULL, " ");
                
        }

        return 0;
}

\\this is I use cout<<s; to display the output of the string

A tin mug for a jar of gum, Nita.
Crazy Monique drove lumberjacks and surfers and six_packers wild, though
wild six_packers and surfers and lumberjacks drove Monique crazy.
Did I draw Della too tall, Edward? I did?
Pack my box with five dozen liquor jugs.
Yow can cage a swallow, can't you? But you can't swallow a cage, can you?
Cigar? Toss it in a can? It is so tragic!
Madam: I, Dennis, Nell, Edna, Anita, Rolf, Nora, Alice, Carol, Lora,
Cecil, Aaro
n, Flora, Tina, and Ellen, sinned. I'm Adam.

//this is the output each time I tokenize the string and I use toupper()

Anyone know why insteed of print out (the whole word) TIN or MUG... it
prints T M just the first letter of the word?
A
T
M
F
A
J
O
G
N
M
D
L
A
S
A
S
W
T
W
S
A
S
A
L
D
M
C
I
D
D
T
T
E
I
D
M
B
W
F
D
L
J
C
C
A
S
C
Y
B
Y
C
S
A
C
C
Y
T
I
I
A
C
I
I
S
T
I
D
N
E
A
R
N
A
C
L
C
A
F
T
A
E
S
I
A
Press any key to continue

Thank if you can help



Relevant Pages

  • Re: need help on using toupper!
    ... Crazy Monique drove lumberjacks and surfers and six_packers wild, ... But you can't swallow a cage, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Origin of a phrase
    ... au>, Stephen Calder writes ... discovered in the wild but released from a cage before the hunt starts so that the party will have one to chase. ...
    (alt.usage.english)
  • Re: Origin of a phrase
    ... discovered in the wild but released from a cage before the hunt starts so that the party will have one to chase. ...
    (alt.usage.english)
  • Re: Origin of a phrase
    ... discovered in the wild but released from a cage before the hunt starts ... so that the party will have one to chase. ...
    (alt.usage.english)