Thread: String functions help

  1. #1
    Registered User
    Join Date
    Jun 2003

    String functions help

    I keep getting this error when I am compiling my program. I am trying to read in this array and then convert all the characters to upper-case, but it is ging me this:

    error C2664: 'toupper' : cannot convert parameter 1 from 'char [30]' to 'int'
            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    Error executing cl.exe.
    #include <iostream.h>
    #include <fstream.h>
    #include <iomanip.h>
    #include <ctype.h>
    #include <stdlib.h>
    #include <string.h>
    //Global variables
    ifstream infile;
    ofstream outfile;
    typedef char str[30];
    //function prototypes
    void tocaps(str []);
    int main()
    int n[30],m[30];
    str name[30];
    		for(int i=0;i<23;i++)
    		infile >> n[i];
    		infile >> m[i];
    		cout << n[i] << endl << m[i] << endl
    		<< name[i] << endl;
    		//change to caps
    		//take off the last characters of middle name
    		//compare to second file
    		//add dashes to social security number and add dashes to phone number
    		//binary search
    	return 0;
    void tocaps(str name[])
    	for(int i=0;i<23;i++)
    		cout << name[i] << endl;

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    toupper() works on single characters, not entire strings. You'd need a nested loop.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    typedef char str[30];
    str name[30];
    See the issue now?

    [edit] Curses, foiled again! [/edit]

    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Jun 2003
    cool, thank you. I had a different example in my notes.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  3. RicBot
    By John_ in forum C++ Programming
    Replies: 8
    Last Post: 06-13-2006, 06:52 PM
  4. Badly designed n string functions?
    By anonytmouse in forum C Programming
    Replies: 3
    Last Post: 11-01-2003, 05:16 AM
  5. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 10:06 PM
Website Security Test