Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
C#
// String_Processingg.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
using namespace std;
#include<stdio.h>
#include<ctype.h>
#include<string>
#include <cstdlib>

void upper(string t  );

int _tmain(int argc, _TCHAR* argv[])
{

    char s[100];

    while(gets(s))
    {
        upper(s);
        puts(s);

    }
    return 0;
}

void upper(string t)
{

    while(*t)
        *t=toupper(*t);
    t++;
}



Errot:No operator ++ and *matches these operand.

Please help remove these error.
thanks in advance
Posted

C#
void upper(char *t );
 
Share this answer
 
Comments
vikrant vaibhav 18-Feb-13 2:30am    
thanks ..
What you have here is rather a C program: all the functions you use are C library functions, not C++ functions.
The whole program is rather carelessly written:
- Don't have "using" between includes.
- Don't mix c-style includes with C++ style C library includes (the C++ style C library includes wrap the C code into namespace std). Choose one style an stick on it.
- Since you decided to use C functions, use the appropriate types (e.g. char buffer instead of string - in that case you have to decide on the string buffer size and use the respective safe gets function - or you may completely avoid a buffer and run the program character wise: getchar/putchar).
- Classical trap of omitting curly braces in a while block: the upper function's while block is brocken due to that: t++ need to be part of the loop.

Is this a code fragmet that you got to correct or is this your own code? It looks rather broken.
Sorry for not giving more clear advise. It looks like homework assignment, and you have to do it yourself to learn something.

Cheers
Andi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900