I'm trying to output a bunch of variables to a file, with 2 numbers and a carriage return on each line.
I have two global int arrays declared all with variables in them.
void FileOutput()
{
FILE *f = fopen ("myfile.txt", "wb");
if (f == NULL) die("Couldn't open myfile.txt for writing, sorry");
else {
int x;
char temp_string[20];
for (x = 0; x <= 4; x++)
{
sprintf(temp_string, "%i %i \n", x_pos[x], y_pos[x]);
//printf("%i %i", x_pos[0], y_pos[0]);
printf("Calm down sir, PLEASE\n");
fputs (temp_string, f);
}
fclose(f);
}
printf("Don't worry sir, I'm from the internet\n");
}
Now, it puts it in the file fine, however, it all comes out as one line. The output on the screen comes out fine and I get carriage returns as expected there, however. I'd like it to come out this like this:
82 103
49 134
953 535
354 53
3535 234
The variables are purely aribtrary, this is an extension of a tutorial I'm following (I'm doing Wii homebrew development). I have to say, I've been doing programming for a while, and yet, I've never come across an issue quite like this that I haven't been able to resolve so easily.
Shoving \n everywhere does nothing (in regards to file output). I've tried injecting it when doing fputs() and also at the sprintf part, neither work. Honestly running out of ideas here. Anyone able to give me a hand figuring out what I'm doing wrong here?
TO be clear I am not running linux today, however I keep thinking about it. And I want to make sure there are minimal obstacles if I decide to make that switch in the coming months.
Yes, I actually glossed over the Linux part from the OP. You could always go for a 9070 XT and if you really want to play Ray Traced games in the future, GeForce Now is pretty damn good on Linux https://www.neowin.net/news/nvidias-native-geforce-now-app-for-linux-bridges-the-gaming-gap-hands-on/
One reason it might be running hotter is dust build up within the cooling or perhaps the paste has dried out. You could always try repasting your old GPU and cleaning the cooler.
Your experience in Linux will be much better with an AMD GPU; the performance in gaming is much closer to Windows than nVidia would be. I personally think on Windows, AMD drivers are junk.
I reviewed it back in March, but I didn't have a 5070 at the time
https://www.neowin.net/reviews/amd-rx-9070-review-vs-rtx-5070-4070-and-rx-9070-xt-7800-xt--just-good-enough/
When I reviewed the 9070 I did have a 5070 to compare it against, so the scores are there for the 9070 XT. it outperforms the 5070 in raster, and is barely neck and neck in Ray Tracing.
So it's better than a 5070 in everything but Ray Tracing where it is neck and neck, or just under.
To be honest, the uplift from 3080 when it was new to the 9070 XT is not as great a step up. If you can find a used 4080 Super for around the same money, you would probably be better off, but if you only want to buy new then the 16GB 9070 XT is the best value for money in its category.
Question
The Teej
Okay, it's 2am, and I'm at my wits end.
I'm trying to output a bunch of variables to a file, with 2 numbers and a carriage return on each line.
I have two global int arrays declared all with variables in them.
void FileOutput() { FILE *f = fopen ("myfile.txt", "wb"); if (f == NULL) die("Couldn't open myfile.txt for writing, sorry"); else { int x; char temp_string[20]; for (x = 0; x <= 4; x++) { sprintf(temp_string, "%i %i \n", x_pos[x], y_pos[x]); //printf("%i %i", x_pos[0], y_pos[0]); printf("Calm down sir, PLEASE\n"); fputs (temp_string, f); } fclose(f); } printf("Don't worry sir, I'm from the internet\n"); }Now, it puts it in the file fine, however, it all comes out as one line. The output on the screen comes out fine and I get carriage returns as expected there, however. I'd like it to come out this like this:
82 103
49 134
953 535
354 53
3535 234
The variables are purely aribtrary, this is an extension of a tutorial I'm following (I'm doing Wii homebrew development). I have to say, I've been doing programming for a while, and yet, I've never come across an issue quite like this that I haven't been able to resolve so easily.
Shoving \n everywhere does nothing (in regards to file output). I've tried injecting it when doing fputs() and also at the sprintf part, neither work. Honestly running out of ideas here. Anyone able to give me a hand figuring out what I'm doing wrong here?
Major thanks in advance.
Link to comment
https://www.neowin.net/forum/topic/997904-c-carriage-return-with-fputs/Share on other sites
14 answers to this question
Recommended Posts