*FILE program question

This is a discussion on *FILE program question within the C Programming forums, part of the General Programming Boards category; I had to write a program that prompts a user for their name in lower case letters, transfers this input ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    11

    *FILE program question

    I had to write a program that prompts a user for their name in lower case letters, transfers this input into a file, read the name in lower case letters from the file, transfer the name into upper case letters, transfer the name in upper case letters into an output file, and display the contents of the output file.

    I eventually figured out to use gets() to get the original string and transferred it into an input file. The problem comes when I read the input file. The only way I can figure out how to do it is to use scanf() to pull the letters out one at a time, do the case conversion, and fprintf() the characters one at a time into the output file. The problem is that everything after the first blank space is lost. Any ideas on how to get the whole string and convert it?

    Colin

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Code:
    fgets ( buf, sizeof buf, IN );
    for ( x = 0; x < strlen ( buf ) - 1; x++ )
      buf[x] = toupper ( buf[x] );
    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question regarding a this C program
    By cnb in forum C Programming
    Replies: 10
    Last Post: 10-11-2008, 04:43 AM
  2. newb question: probs with this program
    By ajguerrero in forum C Programming
    Replies: 5
    Last Post: 04-19-2006, 08:04 AM
  3. Random Question Assign Program
    By mikeprogram in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2005, 09:04 PM
  4. Question type program for beginners
    By Kirdra in forum C++ Programming
    Replies: 7
    Last Post: 09-15-2002, 05:10 AM
  5. Replies: 8
    Last Post: 03-26-2002, 06:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21