两个C ++问题 [英] Two C++ questions

查看:104
本文介绍了两个C ++问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




1.初始化数组的任何更快的方法(除了for-loop)?


2.是否有类似的C ++函数来替换C'的fprintf?


谢谢。


Pat

Hi,

1. Any faster method (other than for-loop) to initialize array?

2. Does there have similar C++ function to replace C''s "fprintf"?

Thanks.

Pat

推荐答案



" Pat" < Pa*@Pat.com>在留言新闻中写道:40 ******** @ rain.i-cable.com ...

"Pat" <Pa*@Pat.com> wrote in message news:40********@rain.i-cable.com...


1.任何更快的方法(其他比for-loop)初始化数组?

2.是否有类似的C ++函数来替换C'的fprintf?

谢谢。

Pat
Hi,

1. Any faster method (other than for-loop) to initialize array?

2. Does there have similar C++ function to replace C''s "fprintf"?

Thanks.

Pat




1)是的,取决于你拥有的阵列类型,例如char数组,数组

ofts / etc。或者类的数组。


2)不完全是,fprintf在C ++中使用< cstdio>标题,或者

你可以使用fstream。


Allan



1) yes, depends which type of array you have though, e.g. char array, array
of ints/etc. or array of classes.

2) not exactly, fprintf is available in C++ using the <cstdio> header, or
you can use an fstream.

Allan




Pat < Pa*@Pat.com>在留言新闻中写道:40 ******** @ rain.i-cable.com ...

"Pat" <Pa*@Pat.com> wrote in message news:40********@rain.i-cable.com...


1.任何更快的方法(其他比for-loop)初始化数组?


C ++没有指定任何操作的速度。如果你想知道哪两个方法更快,唯一的方法是尝试两种方法并计时。


2.是否有类似的C ++函数替换C'的fprintf?
Hi,

1. Any faster method (other than for-loop) to initialize array?

C++ does not specify the speed of any operation. If you want to know which
of two methods is faster the only way is to try both and time them.

2. Does there have similar C++ function to replace C''s "fprintf"?




它没有这样的功能,它有一个完整的库用于输出

称为iostream库。这是一个快速示例,它将一行写入名为fred.txt的

文件。


ofstream output_file(" fred.txt");

output_file<< 数字 << 123<< ''\ n'';


john



It does not have a function as such, it has a whole library for doing output
called the iostream library. Here''s a quick sample that writes a line to a
file called fred.txt.

ofstream output_file("fred.txt");
output_file << "a number " << 123 << ''\n'';

john


谢谢。


我想初始化int和双重阵列。在我的节目中,他们非常好,超过10000个条目。


Pat


" John哈里森" <乔************* @ hotmail.com> | b?l¥ó

新闻:c6 ************ @ID-196037.news.uni-berlin.de¤¤??? g ...
Thanks.

I want to initialize "int" and "double" arrays. In my program, they are very
big, more than 10000 entries.

Pat

"John Harrison" <jo*************@hotmail.com> |b?l¥ó
news:c6************@ID-196037.news.uni-berlin.de ¤¤???g...

Pat < Pa*@Pat.com>在留言新闻中写道:40 ******** @ rain.i-cable.com ...

"Pat" <Pa*@Pat.com> wrote in message news:40********@rain.i-cable.com...


1.任何更快的方法(其他比for-loop)初始化数组?

C ++没有指定任何操作的速度。如果你想知道两种方法中哪种方法更快,唯一的方法是尝试两种方法并计时。

Hi,

1. Any faster method (other than for-loop) to initialize array?

C++ does not specify the speed of any operation. If you want to know which
of two methods is faster the only way is to try both and time them.

2.是否有类似的C ++功能替换C'的fprintf?
2. Does there have similar C++ function to replace C''s "fprintf"?



它没有这样的功能,它有一个完整的库来做



It does not have a function as such, it has a whole library for doing



输出称为iostream库。这是一个快速示例,它将一行写入名为fred.txt的文件。

ofstream output_file(" fred.txt");
output_file<< 数字 << 123<< ''\\ n';;

约翰


output called the iostream library. Here''s a quick sample that writes a line to a
file called fred.txt.

ofstream output_file("fred.txt");
output_file << "a number " << 123 << ''\n'';

john



这篇关于两个C ++问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆