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!
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]
Quote:
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);
Quote:
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
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.
Re: Two Questions - Return at end of paired data points in CSV file, and how to "brea