Click here to Skip to main content
12,398,225 members (50,522 online)
Rate this:
 
Please Sign up or sign in to 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 17-Feb-13 20:16pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

void upper(char *t );
  Permalink  
Comments
vikrant vaibhav 18-Feb-13 2:30am
   
thanks ..
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100