Thread: A student needs help (FILE)

  1. #1
    Registered User
    Join Date
    Nov 2014
    Posts
    1

    Post A student needs help (FILE)

    I'm having trouble in this exercise here.

    Code software that, from an original text file, generate another file with the text content in upper case.

    For exemple:

    entrence:

    luke
    tom
    alex

    outings:

    LUKE
    TOM
    ALEX


    My code so far:

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    int main()
    {
        char variable;
        FILE *file, *file2;
        file = fopen("arquivo.txt","r");
        if (file == NULL)
            printf("error the file was not open\n");
        else {
             while ( (variable = fgetc(file)) != EOF)
                  putchar(file);
                  printf("its ok");
        }
    
    
    
    
      return 0;
    }
    
    

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I suggest that you start by reading from a file, then printing the contents of that file to standard output. Then, you can modify your code to print the contents of that file to standard output, such that the alphabetic contents of the file are in uppercase. Finally, you modify your code again to open the second file for writing, then having the printing be done to that output file instead of standard output.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2014
    Posts
    3
    The easiest way to change letters from upper to lower case, or vice versa, is to use ascii values.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 17
    Last Post: 11-16-2013, 06:18 PM
  2. Student record system; file handling
    By dirtyhabit_12 in forum C Programming
    Replies: 2
    Last Post: 02-25-2013, 02:20 AM
  3. Student record ; file handling
    By dnates2012 in forum C Programming
    Replies: 4
    Last Post: 02-23-2013, 12:13 AM
  4. new student
    By monu in forum C Programming
    Replies: 5
    Last Post: 07-27-2007, 10:18 AM
  5. student binary file program....
    By Newworld in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 08:50 PM

Tags for this Thread