C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 20th, 2006, 09:44 AM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
Anyone pls help

hi, i need some help here as i have been cracking my brains but couldn't come out with any solutions.

currently i have a set of datas that looks as follows
2 -2.020688
2.006 -2.19475
2.012 -2.460067
2.018 -2.826158
2.024 -3.302098
2.03 -3.896182

i need to save these 2 columns of datas into 2 seperate text files or prefably in excel.
Pls help me out here, thanks!!!

Reply With Quote
  #2  
Old December 20th, 2006, 11:48 AM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 428 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 7 h 55 m 4 sec
Reputation Power: 13
If you want to output to two files you need to open two files. Do you know how to write to files?
__________________
USE CODE TAGS: Highlight the code, click on the # button.

Reply With Quote
  #3  
Old December 20th, 2006, 11:52 AM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by Paul820
If you want to output to two files you need to open two files. Do you know how to write to files?

Hi Paul,
really grateful to your reply. i do not know how to write to files as i am a novice in c++...

Reply With Quote
  #4  
Old December 20th, 2006, 12:01 PM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 428 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 7 h 55 m 4 sec
Reputation Power: 13
Ok here is a basic example:

Code:
#include <iostream>
#include <fstream>

using namespace std;

int main( void )
{
    // Some temp variables to put in the files.
    int number1 = 50;
    int number2 = 100;

    // Get two file handles, one for each file.
    ofstream file1;
    ofstream file2;

    // Open the files.
    file1.open( "C:\\dataFile1.txt" );
    file2.open( "C:\\dataFile2.txt" );

    // Now you can use file1, file2 just like cout and cin etc.
    file1 << number1;
    file2 << number2;

    // Close the files.
    file1.close();
    file2.close();

    return 0;
}


When you run that it will create two files, one called dataFile1 with the number 50 inside and the other called dataFile2 with the number 100 inside. Have a go at doing your own and if you get stuck come back and someone will be glad to help you.

Reply With Quote
  #5  
Old December 20th, 2006, 12:08 PM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by Paul820
Ok here is a basic example:

Code:
#include <iostream>
#include <fstream>

using namespace std;

int main( void )
{
    // Some temp variables to put in the files.
    int number1 = 50;
    int number2 = 100;

    // Get two file handles, one for each file.
    ofstream file1;
    ofstream file2;

    // Open the files.
    file1.open( "C:\\dataFile1.txt" );
    file2.open( "C:\\dataFile2.txt" );

    // Now you can use file1, file2 just like cout and cin etc.
    file1 << number1;
    file2 << number2;

    // Close the files.
    file1.close();
    file2.close();

    return 0;
}


When you run that it will create two files, one called dataFile1 with the number 50 inside and the other called dataFile2 with the number 100 inside. Have a go at doing your own and if you get stuck come back and someone will be glad to help you.


Paul thks for the program but i have another problem. The main problem is i have tons of datas, how do i output each column of data that i need into datafile1 and datafile2?

Reply With Quote
  #6  
Old December 20th, 2006, 12:12 PM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 428 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 7 h 55 m 4 sec
Reputation Power: 13
Where is the data?

Reply With Quote
  #7  
Old December 20th, 2006, 12:20 PM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by Paul820
Where is the data?

my datas are stored in a .txt file

Reply With Quote
  #8  
Old December 20th, 2006, 12:25 PM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by kendotan
my datas are stored in a .txt file


Code:
    frequency                                S11                
	    2		              -2.020688
                 2.006  	      	 -2.19475
                 2.012                           -2.460067
                 2.018                           -2.826158
                 2.024                           -3.302098
                  2.03                           -3.896182
                 2.036                           -4.614473
                 2.042                           -5.456934
                 2.048                           -6.408561
                 2.054                           -7.421192
                  2.06                           -8.383409
                 2.066                           -9.096831
                 2.072                           -9.327775
                 2.078                            -8.97559
                 2.084                           -8.172516
                  2.09                           -7.155512
                 2.096                            -6.11014
                 2.102                           -5.136114
                 2.108                           -4.275054
                 2.114                           -3.539096
                  2.12                           -2.927441
                 2.126                           -2.434296
                 2.132                            -2.05236
                 2.138                           -1.774214
                 2.144                           -1.592716
                  2.15                            -1.50096
                 2.156                            -1.49197
                 2.162                           -1.558237
                 2.168                           -1.691128
                 2.174                           -1.880176
                  2.18                           -2.112333
                 2.186                           -2.371329
                 2.192                           -2.637426
                 2.198                           -2.888039
                 2.204                            -3.09966
                  2.21                           -3.251243
                 2.216                            -3.32839
                 2.222                           -3.326841
                 2.228                           -3.253601
                 2.234                           -3.125139
                  2.24                           -2.963568
                 2.246                           -2.792547
                 2.252                           -2.634238
                 2.258                           -2.507729
                 2.264                           -2.428699
                  2.27                           -2.409806
                 2.276                           -2.461403
                 2.282                           -2.592348
                 2.288                           -2.810739
                 2.294                           -3.124605
                   2.3                           -3.542503
                 2.306                           -4.074056
                 2.312                             -4.7304
                 2.318                           -5.524384
                 2.324                           -6.470091
                  2.33                           -7.580419
                 2.336                           -8.859348
                 2.342                           -10.28037
                 2.348                           -11.73423
                 2.354                           -12.94263
                  2.36                           -13.46915
                 2.366                           -13.08326
                 2.372                           -12.05935
                 2.378                           -10.82796
                 2.384                           -9.647054
                  2.39                           -8.613956
                 2.396                           -7.750452
                 2.402                           -7.051011
                 2.408                           -6.502326
                 2.414                           -6.090211
                  2.42                           -5.801685
                 2.426                           -5.625306
                 2.432                           -5.550878
                 2.438                           -5.568943
                 2.444                           -5.670171
                  2.45                           -5.844721
                 2.456                           -6.081584
                 2.462                           -6.367967
                 2.468                           -6.688871
                 2.474                           -7.027062
                  2.48                           -7.363755
                 2.486                           -7.680256
                 2.492                           -7.960545
                 2.498                           -8.194287
                 2.504                           -8.379268
                  2.51                           -8.522229
                 2.516                           -8.637736
                 2.522                           -8.745634
                 2.528                           -8.868144
                 2.534                           -9.027571
                  2.54                           -9.244967
                 2.546                           -9.539741
                 2.552                           -9.929814


something as above will be my datas in text file, therefore i need to save frequency and s11 results separately

Reply With Quote
  #9  
Old December 20th, 2006, 12:29 PM
Geo.Garnett's Avatar
Geo.Garnett Geo.Garnett is offline
Registered Loser
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347 Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level)Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 13
Send a message via AIM to Geo.Garnett
Well, if you need to read from a file and then output to some files then you need to open a file to first read the data as well as creating variables to hold that data for later outputting them to your two seperate files. You might want to look into this link below and it might clear up a lot of this without us having to walk you through it step by step. =)
http://www.cplusplus.com/doc/tutorial/files.html
Look that over and then see if that helps. Thats a step by step description of how to get data from a file as well as outputting what you got.
__________________
---Official Member Of The Itsacon Fan Club---
Give a man a fish and he will eat for a day. Teach a man to fish and he will sit in a boat all day drinking beer.

Reply With Quote
  #10  
Old December 20th, 2006, 12:33 PM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 428 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 7 h 55 m 4 sec
Reputation Power: 13
Well if all you need to do is read the data file and then put the results into two other files you could do this:

Code:
#include <iostream>
#include <fstream>

using namespace std;

int main( void )
{
    // Get two file handles, one for each file.
    ofstream file1;
    ofstream file2;
    // File to read from.
    ifstream dataFile;

    // Open the files.
    file1.open( "C:\\dataFile1.txt" );
    file2.open( "C:\\dataFile2.txt" );
    dataFile.open( "C:\\dataFile.txt" );

    if ( !dataFile )
    {
        cerr << "Failed to open the file." << std::endl;

        return 1;
    }

    double num1, num2;
    while ( dataFile )
    {
        dataFile >> num1;
        file1 << num1 << endl;
        dataFile >> num2;
        file2 << num2 << endl;
    }

    // Close the files.
    file1.close();
    file2.close();
    dataFile.close();

    return 0;
}


But if you wanted to do more with the data you should read it into arrays or vectors. Hope this helps you.

Reply With Quote
  #11  
Old December 20th, 2006, 12:50 PM
Geo.Garnett's Avatar
Geo.Garnett Geo.Garnett is offline
Registered Loser
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347 Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level)Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 13
Send a message via AIM to Geo.Garnett
Well, since Paul already solved the problem. Here is another example of how this can be done. Like he said by putting the values you get into an array. Very simple prog.
Code:
#include <cstdlib>
#include <iostream>
#include <fstream>
#define MAX 256 //Tryies to account for all possibilities

using namespace std;

int main()
{
    //Used for reading the file.
    ifstream readfile("InputFile.txt");
    //First output file for column 1
    ofstream outfile1("Frequency.txt");
    //Second output file for column 2  
    ofstream outfile2("S11.txt"); 
    //Used to get the initial string
    string str;
    //Used to store values in the file
    string freq[MAX]; 
    //Used for the s11 values
    string s11[MAX]; 
    if(readfile.is_open())
    {
               int i = 0;
                          while(!readfile.eof())
                          {
                                  //Reads the first string up to the whitespace
                                  readfile>>str;
                                  //Displays it on screen. Not neccessary.
                                  cout<<str<<endl;
                                  //Puts the value of str into the array
                                  freq[i] = str;
                                  //Outputs the value to the text file
                                  outfile2<<freq[i]<<endl;
                                  
                                  //Does it again for the second colum and stores it
                                  //to another array.
                                  readfile>>str;
                                  cout<<str<<endl;
                                  s11[i] = str;
                                  outfile1<<s11[i]<<endl;
                                  i++;
                                  }
                                  }
                                  //Closes files
                                  readfile.close(); 
                                  outfile1.close();
                                  outfile2.close();
                                  
    cout<<"Press Enter to exit program\n";
    cin.get();
    return 0;
}

I would still suggest going over that link now that you have this problem solved because I/O stuff is a big part of programming in my opinion, so you need to be familiar with how to manipulate files. ; )

Last edited by Geo.Garnett : December 20th, 2006 at 01:16 PM.

Reply With Quote
  #12  
Old December 20th, 2006, 12:55 PM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by Paul820
Well if all you need to do is read the data file and then put the results into two other files you could do this:

Code:
#include <iostream>
#include <fstream>

using namespace std;

int main( void )
{
    // Get two file handles, one for each file.
    ofstream file1;
    ofstream file2;
    // File to read from.
    ifstream dataFile;

    // Open the files.
    file1.open( "C:\\dataFile1.txt" );
    file2.open( "C:\\dataFile2.txt" );
    dataFile.open( "C:\\dataFile.txt" );

    if ( !dataFile )
    {
        cerr << "Failed to open the file." << std::endl;

        return 1;
    }

    double num1, num2;
    while ( dataFile )
    {
        dataFile >> num1;
        file1 << num1 << endl;
        dataFile >> num2;
        file2 << num2 << endl;
    }

    // Close the files.
    file1.close();
    file2.close();
    dataFile.close();

    return 0;
}


But if you wanted to do more with the data you should read it into arrays or vectors. Hope this helps you.


Paul thks for your help!!! i am very grateful to you.
i have written a program in storing the datas into vectors. Could you kindly pls tell me if this is the right way to store my datas. thks!!!!
Code:
#include "stdafx.h"


#include <iostream>


#include <fstream>


#include <iomanip>

#include <vector>

using namespace std;


int main()
{

ifstream file_to_read("M:\a5110_measurement\test7.txt");

vector<float> frequency_array,
s11_array;

while(!file_to_read.eof()) {

float frequency,
s11;

file_to_read >> frequency >> s11; 


frequency_array.push_back(frequency);
s11_array.push_back(s11);

}


return 0;
}
Comments on this post
Geo.Garnett agrees: Good idea using the eof() to end the loop.

Reply With Quote
  #13  
Old December 20th, 2006, 12:56 PM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 428 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 7 h 55 m 4 sec
Reputation Power: 13
I agree Geo.Garnett, dealing with files is important in programming. He should read as much as he can about them. None of us can tell him all he needs to know.

Reply With Quote
  #14  
Old December 20th, 2006, 01:09 PM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 428 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 7 h 55 m 4 sec
Reputation Power: 13
You need two backslashes on these:

Code:
ifstream file_to_read("M:\a5110_measurement\test7.txt");


So it reads:
Code:
ifstream file_to_read("M:\\a5110_measurement\\test7.txt");


Otherwise, you see where it says \test, the t in test is seen as a tab. Use two backslashes when finding your files. Did you run it? Run the file file and then check for any errors.

Reply With Quote
  #15  
Old December 20th, 2006, 01:19 PM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 428 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 7 h 55 m 4 sec
Reputation Power: 13
Quote:
Geo.Garnett agrees: Good idea using the eof() to end the loop.


He only needs
Code:
while ( file_to_read )


That will check for end-of-file anyway.

Reply With Quote
  #16  
Old December 20th, 2006, 01:22 PM
Geo.Garnett's Avatar
Geo.Garnett Geo.Garnett is offline
Registered Loser
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347 Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level)Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 13
Send a message via AIM to Geo.Garnett
Yes yes, I was just meaning, using end of file to tell the loop when to stop. I updated my prog to use it because I was rushing through and didn't even think to use it. And if he wants the file to loop until the end of the file I believe that he would because of the ! <- not operator. while its not the eof then run his loop

Last edited by Geo.Garnett : December 20th, 2006 at 01:25 PM.

Reply With Quote
  #17  
Old December 20th, 2006, 01:25 PM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by Geo.Garnett
Yes yes, I was just meaning, using end of file to tell the loop when to stop. I updated my prog to use it because I was rushing through and didn't even think to use it.

hi geo, i tried out your program there were some errors...

m:\test\as\5\5\5.cpp(33) : error C2784: 'std::basic_ostream<char,_Traits> &std:perator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::string'
e:\program files\microsoft visual studio 8\vc\include\ostream(927) : see declaration of 'std:perator <<'

What does it means? Thks!!

Reply With Quote
  #18  
Old December 20th, 2006, 01:28 PM
Geo.Garnett's Avatar
Geo.Garnett Geo.Garnett is offline
Registered Loser
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347 Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level)Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 13
Send a message via AIM to Geo.Garnett
Well, Im using Dev-C++ and if you didn't copy and paste exactly and forgot the "using namespace std;" , that could be the cause of the std:: problem. Check for it and if its not in there put it in and see what you get. make sure you dont have some of your code left in there.

Last edited by Geo.Garnett : December 20th, 2006 at 01:31 PM.

Reply With Quote
  #19  
Old December 20th, 2006, 01:31 PM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by Geo.Garnett
Well, Im using Dev-C++ and if you didn't copy and paste exactly and forgot the "using namespace std;" , that could be the cause of the std:: problem. make sure you dont have some of your code left in there.


ok, i copied and paste exactly but the same errors still occur

Reply With Quote
  #20  
Old December 20th, 2006, 01:32 PM
Geo.Garnett's Avatar
Geo.Garnett Geo.Garnett is offline
Registered Loser
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347 Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level)Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 13
Send a message via AIM to Geo.Garnett
Could be a compiler issue because your using visual studio, so not sure man. Compiles fine on my end.

Reply With Quote
  #21  
Old December 20th, 2006, 01:35 PM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 428 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 7 h 55 m 4 sec
Reputation Power: 13
Did you include string?

Reply With Quote
  #22  
Old December 20th, 2006, 01:41 PM
Geo.Garnett's Avatar
Geo.Garnett Geo.Garnett is offline
Registered Loser
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347 Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level)Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 13
Send a message via AIM to Geo.Garnett
That could be it, I knowin dev you dont have to because iostream takes care of that for you but visual studio might not have the same copy or something =S.

Reply With Quote
  #23  
Old December 20th, 2006, 01:47 PM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by Geo.Garnett
That could be it, I knowin dev you dont have to because iostream takes care of that for you but visual studio might not have the same copy or something =S.



yes it was the string header tats missing

Reply With Quote
  #24  
Old December 20th, 2006, 01:56 PM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
just an enquiry, i tried out geo's program but there was no output as expected. Could it be that my text file datas must be aligned accordingly before running the program?
THks!!

Reply With Quote
  #25  
Old December 20th, 2006, 02:02 PM
Geo.Garnett's Avatar
Geo.Garnett Geo.Garnett is offline
Registered Loser
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347 Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level)Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 13
Send a message via AIM to Geo.Garnett
the name of the input file must be in the directory of the exe and also named the same as the one I used, Which was InputFile.txt. If it is a different name then it didnt do anything except create the files and put them in the directory. So basically take your text file put it in your makefile directory of your program then name it InputFile.txt and then run the prog again, and then you should get output to the files =).

Reply With Quote
  #26  
Old December 20th, 2006, 02:09 PM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by Geo.Garnett
the name of the input file must be in the directory of the exe and also named the same as the one I used, Which was InputFile.txt. If it is a different name then it didnt do anything except create the files and put them in the directory. So basically take your text file put it in your makefile directory of your program then name it InputFile.txt and then run the prog again, and then you should get output to the files =).


hey geo thks alot your program works fine!!! the only problem is that it saves the results in opposite files... But really thanks alot!!!

Reply With Quote
  #27  
Old December 20th, 2006, 02:20 PM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
paul and geo i really am grateful to both of you for helping me out. I will brush out my c++ from the website, once again thanks for offering help within your precious time.

Reply With Quote
  #28  
Old December 20th, 2006, 02:25 PM
Geo.Garnett's Avatar
Geo.Garnett Geo.Garnett is offline
Registered Loser
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347 Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level)Geo.Garnett User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 13
Send a message via AIM to Geo.Garnett
Well if you want it to only one file you need to take away the second ofstream file and just modify the code alittle to reflect that change. I thought you want the results to output to seperate files, one for each column of information. Well, like I said I rushed a little cause im at work but you can just play around with the output of it which is the "outfile1<<" and see what you come up with. ; )

Reply With Quote
  #29  
Old December 20th, 2006, 02:43 PM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by Geo.Garnett
Well if you want it to only one file you need to take away the second ofstream file and just modify the code alittle to reflect that change. I thought you want the results to output to seperate files, one for each column of information. Well, like I said I rushed a little cause im at work but you can just play around with the output of it which is the "outfile1<<" and see what you come up with. ; )


i will thks!!!

Reply With Quote
  #30  
Old December 20th, 2006, 02:57 PM
kendotan kendotan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 16 kendotan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by kendotan
i will thks!!!


sorry to trouble again, the program only saves the output halfway, how do i increase the size to save the whole data?

Thks!!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Need Help!!!!


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap