Looping and caling in a text file C++


 
Thread Tools Search this Thread
Top Forums Programming Looping and caling in a text file C++
# 1  
Old 07-14-2013
Looping and caling in a text file C++

Hi ,

I am trying to create a loop to call in the entries from the text file named Set.
The entries of Set.txtare :
Code:
1 2 3
2 4 5 
and so on .. (64 such combinations)

it basically means the first combination for testing is 1 2 3 and next has to be 2 4 5 and so i have 64 such entries defined in set

my test files are located in D://data// and are named tst_data1 to tst_data64.


i created a loop for test set but its incorrect
Code:
// loop for test samples
	char basefilename[] = "D://data//"; 	
	char , testFilen[160], numiChar[10];

	for (int i=1; i<=64; i++) {
	strcpy(basefilenme, "D://data//");			
	strcat(testfilename, Set[]);


					if (testfilenme[i]=='_' && testfilenme[i+1]=='\0'){
						strcat(testfilename, numiChar);
						strcat(testfilename, "_");
						break;
					}					
												
				strcat(testfilename, ".txt");
				cout<<testfilename<<endl;

please correct me how can i call the Set .txt and how to define it.

thanksSmilieSmilie

Last edited by Don Cragun; 07-15-2013 at 01:45 PM.. Reason: Code tags
# 2  
Old 07-18-2013
I guess you are saying you want STL object containers, which contain other objects, which if they are your lines, would contain three objects, which look to be int. In C++, less char and str*(). string - C++ Reference Not seeing anything like open and read, error checking/exception catching for short input, not digits?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies

2. Shell Programming and Scripting

Need help with looping through file contents

Hi, I have a several files with ".out" extension in a folder and each file has the below like contents .... appname: wonder1 ..... logname78.log logname88.log ..... CAP: 2 ..... appname: wonder54 ...... logname28.log logname58.log logname54.log ..... CAP: 3 ..... (4 Replies)
Discussion started by: mohtashims
4 Replies

3. Shell Programming and Scripting

Looping inside directories based on a file which contains file directory list

Hi All, Please help. I have got a file which contains a listing of a file and some directories after it, one by one. I am calling this file xyz.txt here file1 dir1 dir2 dir3 dir4 file2 dir5 dir6 dir7 dir8 file3 dir9 dir10 dir11 dir12 (6 Replies)
Discussion started by: Piyush Jakra
6 Replies

4. Shell Programming and Scripting

FILE_ID extraction from file name and save it in CSV file after looping through each folders

FILE_ID extraction from file name and save it in CSV file after looping through each folders My files are located in UNIX Server, i want to extract file_id and file_name from each file .and save it in a CSV file. How do I do that? I have folders in unix environment, directory structure is... (15 Replies)
Discussion started by: princetd001
15 Replies

5. Shell Programming and Scripting

Looping over a file to count common fields from another file

Hi, I would like to know how can I get the number of rows in file1 that: - the 1st and 2nd field should be the same (text) - the 3rd field should be less or equal (numeric) when comparing to file2. So for each row of file1, I would like to have the number of rows in file2 that follow the... (5 Replies)
Discussion started by: fadista
5 Replies

6. Shell Programming and Scripting

While or For with looping contructs? to create files from contents of a text file

Hi so far I created this script: vi loop.beta.sh for i in `cat extract.filenames.tabc` do echo $i done>$i === This is the original text file. $ more tabc.txt -rwx------- 1 alice staff 1586 2010-11-05 02:27 request-key .conf -rwx------- 1 ted staff 126 ... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

7. Shell Programming and Scripting

Looping within the elements of a file using awk

Hi all, I have a file containing 5000 rows and 4 columns. I need to do a loop within the rows based on the values of column 3. my sample data is formatted like the ones below: what i need to do is to make a loop that will allow me to plot the values of x,y,values corresponding to month 1 to month... (10 Replies)
Discussion started by: ida1215
10 Replies

8. Shell Programming and Scripting

Looping through only blank lines of a file.

I am sorry if I am posting in wrong thread. Experts, I have 2 files File 1 File 2 line1 line1 | line2 line2 | group 1 line3 line3 | line1 line1 | line2 ... (6 Replies)
Discussion started by: suraj.sheikh
6 Replies

9. Shell Programming and Scripting

Looping through each line of text file

Dear all, I have a text file like below. eg.txt abcd efgh ijkl mnop I need a script, which should read the text file eg.txt and assign each line as a parameter. This , i wil use further to pass it a java command to invoke. All inside a for loop Need your help on this. With... (2 Replies)
Discussion started by: KrishnaSaran
2 Replies

10. Shell Programming and Scripting

looping for each file

HI I want to execute the awk command for each file which is of form *.event I am trying the following code but it is not working , #! /bin/csh set h= *.event foreach h(*) set v= `awk -F, 'NR==2 {print $1}' $h` echo $v end But I am getting an error Can somebody correct me Thanks arif (1 Reply)
Discussion started by: mab_arif16
1 Replies
Login or Register to Ask a Question