Thread: Basic Programming

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    1

    Smile Basic Programming

    I am trying to Ccate a program that will read from a file, a list of
    any sort(numbers, strings, names, etc. ) store them into an array and print them out in reverse order into an output file. Could someone please get me started?

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    1) Look in the FAQ for file I/O
    2) Look up sorting routines
    3) The rest is easy
    4) Gratz on being the 300th member!

  3. #3
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    Posts
    742
    Code:
    //open the file
    FILE *fptr = fopen(filename,"r"); if(fptr == NULL) exit(1);
    //read input
    int i_array[20];
    int i=0;
    while(fscanf(fptr,"%d",&i_array[i]) != NULL)
    {
       ++i;
       if(i >= 20) break;
    }
    --i;
    while(i > 0)
    {
       printf("%d\n", i_array[--i]);
    }
    I didn't test this but it should be right or else close to perfect or whatever the hell...
    I compile code with:
    Visual Studio.NET beta2

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [ANN] New script engine (Basic sintax)
    By MKTMK in forum C++ Programming
    Replies: 1
    Last Post: 11-01-2005, 10:28 AM
  2. what are your thoughts on visual basic?
    By orion- in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-22-2005, 04:28 AM
  3. visual basic vs C or C++
    By FOOTOO in forum Windows Programming
    Replies: 5
    Last Post: 02-06-2005, 08:41 PM
  4. Basic Graphics programming in C, please help
    By AdRock in forum Game Programming
    Replies: 3
    Last Post: 03-24-2004, 11:38 PM