Thread: Initializomg a global variable from a data file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    30

    Initializomg a global variable from a data file

    (**I am sorry for the spelling mistake in the title**)

    What's the syntax for initializing a global variable with a number in a data file?
    I only know how to change the value of a variable from a data file using an ifstream variable and the >> operator. However I can't (or don't know how to) use the >> operator outside of the main function.

    For instance, if the name of the data name is info.dat and it has only one number - 100 in it. How would you initialize a global variable, say it is called a, from info.dat, the data file?

    Thanks.
    Last edited by cybernike; 06-27-2007 at 12:12 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. Doing calculations on a data file
    By bassist11 in forum C Programming
    Replies: 2
    Last Post: 03-30-2009, 07:47 PM
  3. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  4. Writing and modifying data in a file
    By Micko in forum C Programming
    Replies: 2
    Last Post: 02-17-2005, 03:42 AM