-
January 24th, 2013, 01:51 PM
#1
Two Questions - Return at end of paired data points in CSV file, and how to "break"
I am using the following line to write pairs of data files. I am hoping to create a CSV file.
CODE fprintf(f, "%d,%f", Universe.year, Universe.R); CODE
This simply writes pairs of data on the same line. I'd like pairs of data on individual lines. This means I need to insert a line feed, somehow, perhaps via a character insertion. Could someone please tell me how to do this easily?
Finally, my memory is very vague on C programming. Is the proper means to exit a loop an if then statement containing the term "break"? How would that be implemented?
Thank you!
Last edited by Protocol; January 24th, 2013 at 01:54 PM.
-
January 24th, 2013, 02:15 PM
#2
Re: Two Questions - Return at end of paired data points in CSV file, and how to "brea
Code tags are done like this:
[code]
Your code goes here
[/code]
This simply writes pairs of data on the same line. I'd like pairs of data on individual lines. This means I need to insert a line feed, somehow, perhaps via a character insertion.
Code:
fprintf(f, "%d,%f\n", Universe.year, Universe.R);
Is the proper means to exit a loop an if then statement containing the term "break"?
There isn't just one way to exit a loop.
Code:
bool someCondition = true;
for (int i = 0; i < someValue && someCondition; ++i)
{
if ( I_want_to_exit_early)
{
someCondition = false;
continue;
}
}
or
Code:
for (int i = 0; i < someValue; ++i)
{
// if the loop needs to terminate prematurely
if ( I_want_to_exit_early )
break;
//...
}
Regards,
Paul McKenzie
-
January 24th, 2013, 02:33 PM
#3
Re: Two Questions - Return at end of paired data points in CSV file, and how to "brea
Got the line feed to work by adding \n after the float output formatting code. Still need to verify the "break" from loop solution.
-
January 24th, 2013, 02:34 PM
#4
Re: Two Questions - Return at end of paired data points in CSV file, and how to "brea
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|