[英]is there a way to get a text file of the cmd prompt? that is, all the data that printf shows in codeblocks c?
I'm currently writing a bunch of calculations in c using codeblocks and printing them off to the cmd prompt using the printf(); 我目前正在使用代码块在c语言中编写大量计算,并使用printf()将它们打印到cmd提示符下; function.
功能。 I am trying to create a graph from the data gathered.
我正在尝试从收集的数据创建图形。 Is there a ways to get a hard copy or a text/doc file of all the data I printed out or better yet, is there a way to get all the values on the cmd prompt into a graph?
有没有办法获得我打印出的所有数据的纸质副本或文本/ doc文件,或者更好的方法?有没有办法将cmd提示符下的所有值都变成图形?
Why don't you just save them to a file? 您为什么不将它们保存到文件中?
Great example of writing to a file: 写入文件的好例子:
FILE *f = fopen("file.txt", "w");
if (f == NULL)
{
printf("Error opening file!\n");
exit(1);
}
/* print some text */
const char *text = "Write this to the file";
fprintf(f, "Some text: %s\n", text);
/* print integers and floats */
int i = 1;
float py = 3.1415927;
fprintf(f, "Integer: %d, float: %f\n", i, py);
/* printing single chatacters */
char c = 'A';
fprintf(f, "A character: %c\n", c);
fclose(f);
Another solution is just pipeing the output using > file.txt
另一种解决方案是使用
> file.txt
通过管道传递输出
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.