sequential access files?

This is a discussion on sequential access files? within the C++ Programming forums, part of the General Programming Boards category; now im getting all zero's......

  1. #16
    Registered User
    Join Date
    Feb 2010
    Location
    Seattle Washington
    Posts
    20
    now im getting all zero's...

  2. #17
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Anytime you have an issue post the code.

    It's the only way I can help you. Cause I don't know what you actually changed.
    Woop?

  3. #18
    Registered User
    Join Date
    Feb 2010
    Location
    Seattle Washington
    Posts
    20
    Code:
    #include<iostream>
    #include<fstream>
    
    using namespace std;
    
    int main()
    {
    	short number = 0;
    	short evenNumber = 0;
    
    	ofstream outfile;
    	ifstream infile;
    	outfile.open ("evennumList.txt",ios.app);
    	infile.open ("numberList.txt",ios.in);
    
    	if (infile.is_open()== false)
    		cout << "Error"<<endl;
    	else
    		while(infile >> number)
    		{
    			infile >> number;
    			
    			if (num%2 == 0)
    			{
    				outfile << evenNumber << endl;
    			}
    		}
    		infile.close();
    		outfile.close();
    
    		return 0;
    Last edited by swansea; 04-29-2010 at 05:17 PM.

  4. #19
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Need to change evenNumber to just number, since that is the value you are checking for even.

    That is why it is always 0, because the value of evenNumber never changes.
    Woop?

  5. #20
    Registered User
    Join Date
    Feb 2010
    Location
    Seattle Washington
    Posts
    20
    oh yeah duh


    thanks

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Header files and multiple definitions
    By sjweinberg in forum C++ Programming
    Replies: 16
    Last Post: 07-17-2009, 05:59 PM
  2. Access file's info in MINIX
    By Zuko in forum Linux Programming
    Replies: 3
    Last Post: 01-07-2008, 09:14 AM
  3. Replies: 3
    Last Post: 09-22-2003, 09:48 PM
  4. How to Access a Function from Multiple Files?
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 06-08-2002, 06:24 PM
  5. Random Access Files
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 08-29-2001, 08:06 AM

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