Thread: New programmer here!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    5

    New programmer here!

    Hello all,

    Does anyone know how to read a file, one character at the time, into an character array? No matter what I try I cant seem to get it to work.
    Edit:
    The size of the file is unknown...it will be different each time the program is run, and it could end up being very large.
    My main problem is putting the characters in an array when I don't know how many elements to define for the array.

    Here is the basic code i have:
    Code:
    int count;
    char *key="something here";
    FILE *in;
        if (( in = fopen("tmp.tmp", "rb")) == NULL) 
       {
          printf("Error opening %s.n", "");
       }
       while(( count = getc(in)) != EOF) 
       {
          count = count ^ *key; 
       //store here
       }
    }
    Last edited by Phob0s; 05-02-2006 at 04:10 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What game programmer should I be? need some advice.
    By m3rk in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 04-20-2009, 11:12 PM
  2. When are you REALLY a programmer?
    By m.mixon in forum C Programming
    Replies: 5
    Last Post: 07-19-2006, 09:08 PM
  3. Senior 3D Programmer - Moab Studios™ LLC
    By moab in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 08-30-2005, 10:19 PM
  4. Me as a programmer?
    By Cheeze-It in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 03-31-2002, 06:19 PM
  5. I need to interview professional programmer.....please
    By incognito in forum C++ Programming
    Replies: 1
    Last Post: 01-05-2002, 02:46 PM