hi there people i was hoping i could get some help please as im kinda stuck. ive have been asked for my uni portfolio to
"accept the characters from a data file rather than from the keyboard. Extend the program to convert all the characters to upper case (excluding numeric characters) and save the characters to a new data file."

at the moment i have managed to copy the file and save it to a new file but i am having trouble converting the info into uppercase can anyone help me please??
here is my code atm

#include <stdafx.h>
#include <ctype.h>
#include <cstdio>

int _tmain(int argc, _TCHAR* argv[])
  int ch;
  int user;
  FILE *pt;
  FILE *upper;

   pt = fopen( "portfolio2.txt", "r" );
   upper = fopen( "upper.txt", "w" );
   printf("Do You Want To Convert Characters To Uppercase \nPlease Enter 1 For Yes 0 For No\n");
   if (user == 1)
    ch = getc(pt);
    while(ch != EOF)
     putc(ch, upper);
     ch = getc(pt);
	return 0;

thanks in advance

8 Years
Discussion Span
Last Post by Narue

hi i did try and add in the toupper function but it wouldnt work and my teacher kinda sucks and isnt really helping i think the code i added was
i thought this would convert all the text to uppercase but for some reason it didnt
thanks though


>i thought this would convert all the text to uppercase but for some reason it didnt
You didn't do anything with the result. toupper returns the converted value, it doesn't (and can't) change the argument because it's passed by value.

ch = toupper ( ch );

>thanks though
FYI, I find that incredibly insulting. It's like saying "I found your help completely worthless, but I'll pretend to be polite anyway".


sorry mate didnt mean 2 be rude i apperciate your help it means alot il try this now thanks
hey thanks narue it worked like a treat its true u learn somthing new everyday sorry bout b4.
can this thread be locked now please thanks


Although, if you're doing it for class of some sort, wouldn't it be better to make your own toupper? Just a thought.
Remember, letters are stored actually as ascii code, and you can "add" them or even compare them ('a' > 'A' i think, maybe opposite)


>Remember, letters are stored actually as ascii code
There's no requirement that characters be stored as ASCII in C++. Assuming any relation beyond the decimal digits (which are required to have consecutive values) is non-portable and a bad practice to encourage.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.