qr 发帖数: 2016 | 1 推荐你一个吧,fstream,自己加任何mms格式的在线radio。 |
|
qr 发帖数: 2016 | 2 下free的Moss吧,自己搜索mms类的电视和电台link加进去就行了,连接速度不错(可
能稍微比fstream慢一点,但这个是可以支持视频的),可以3G,比过去那个streamer
强百倍了。 |
|
f*******5 发帖数: 10321 | 3 世界杯就用football和tvuplayer
mitbbs
IM+
天气预报twc
wallet记些重要信息
fstream,douban锻炼时听,等等
这些我都放folders外边。放folders里边的确实都是没用的。呵呵 |
|
qr 发帖数: 2016 | 4 fstream is the best so far but sorry not rtsp support. |
|
|
j*********g 发帖数: 3179 | 6 I tried fstream. only got one station to work. may try this one sometime. |
|
l*****7 发帖数: 280 | 7 用fstream,不知道怎么设置新的电台啊。只有一个preset的classic。 |
|
|
y***n 发帖数: 6764 | 9 用的是fstream + iphone 4, 有没有地址的update? 多谢! |
|
|
s***e 发帖数: 122 | 11 那最好还是定义一个自己的输出输入类吧。这样以后万一修改代码的时候也不容易漏掉
。刚才写了一个例子,也是做个练习,呵呵,以前也没有自己写过。你就作为一个参考
吧。
// MyIn.h
#ifndef _MY_IN_H_
#define _MY_IN_H_
#include
#include
#include
class MyIn
{
private:
std::ofstream& ofs;
public:
MyIn(std::ofstream& o);
public:
MyIn& operator >> (int& i);
MyIn& operator >> (std::string& s);
};
#endif
// MyIn.cpp
#include "MyIn.h"
MyIn::MyIn(std::ofstream& o):ofs(o) {
}
MyIn& MyIn::operator >> (int& i) {
std::cin >> i;
ofs << i << std::endl;
return *this;
} |
|
d***a 发帖数: 316 | 12 想法是用户输入一个文件名,例如 someresults.txt
然后用ifstream读入,处理后,用ofstream保存为 someresults_data_extracted.txt
用户输入的文件后缀要去掉。
以下是产生问题的部分code,其它省略。
整个程序g++编译通过的。
#include
#include
#include
#include
cout << "Enter the file to work on: ";
string originName;
getline(cin, originName);
// code for ifstream to read a file
…..
char * tempOut = new char [originName.size()+16];
strncpy(tempOut, originName.c_str(), originName.size()-4);
ofstream fout;
fout.open( strcat(tempO... 阅读全帖 |
|
Y********6 发帖数: 28 | 13 刚开始学,第三堂课就遇到困难。。。实在弄不出来。。。
题目是这样的
* Write a program that reads from a file called input.txt until the file
contains the word end.
* For each word you encounter, you will determine if the word is
alphabetically before or after the previous encountered word.
* For a word that is alphabetically after the previous word, write the word
to the screen and then say AFTER. For words that are before the previous,
write the word BEFORE. For the first word, write COMES FIRST. For words that
are the same, wr... 阅读全帖 |
|
l********a 发帖数: 1154 | 14 又来一次
#include
#include
#include
using namespace std;
int main()
{
ifstream fin("test.txt");
string curWord, lastWord = "";
fin >> curWord;
while (curWord.compare("end")!=0)
{
if (lastWord.empty())
{
cout << curWord << " COMES FIRST" << endl;
}
else if (curWord>lastWord)
{
cout << curWord << " AFTER " << lastWord << endl;
}
else if (curWord
{
... 阅读全帖 |
|
x****u 发帖数: 44466 | 15 你是完全无视一切技术问题,专门钻牛角尖啊。你先搞清楚win api和native api的区
别再来吧。抬杠的话我主动认输。
我写了个程序用到了fstream,因为它被翻译成了unix系统调用open什么的,这个程序
就不是linux native的了?你是不是故意在混淆概念啊。 |
|
b****t 发帖数: 114 | 16 Hi all,
I want to append new column data to a data file. The data has been formated
in a tabbed way (very clean data without any missing/empty cells). This is
usefull when I run my c/c++ code and save data each time as one or more
columns. Ideally, it will be done within c/c++ code with fstream, but it is
ok to use stript split single (or 2 column) column data into multiple
columns.
e.g.
file1:
1 2 3
2 3 4
5 6 7 |
|
s******r 发帖数: 21 | 17
Here is my solution. It is not necessarily the simplest one.
I use f.seek(-60, ios::end) here, assuming:
1. the data file is in Text Format;
2. the last 2nd number is always within the last 60 bytes of the data file.
The last 2nd element in the vector v is what you want, then.
#include
#include
#include
#include
using namespace std;
int main(void){
ifstream f("1.data");
f.seekg(-60, ios::end);
vector v((istream_iterator(f)), istream_itera |
|
x*****u 发帖数: 3419 | 18 感谢! 但感觉这个-60不好把握,多了少了都成问题。
用getline应该更稳妥一点。
1 // istringstream::str
2 #include
3 #include
4 #include
5 #include
6 using namespace std;
7
8 int main () {
9
10 double val;
11
12 string file_name("Tnve.dat");
13 ifstream infile(file_name.c_str(),ios::in);
14 istringstream iss;
15 string strvalues,sv;
16
|
|
t***g 发帖数: 193 | 19 Clock() always returns zero, anyone knows the reason?
sample code:
#include
#include
#include
using namespace std;
int main(){
for(long i=0;i<10;i++)
cout << clock() <
return 0;
}
Thanks a lot. |
|
g*******s 发帖数: 59 | 20 i am using visual studio 2005 to test the use of getline.
The text file is like:
test.txt
a is a file
1.0 2.0
b isnot a file
3.0 4.0
The codes r
#include
#include
#include
using namespace::std;
void main()
{
string zz,zz1;
ifstream fin("test.txt");
getline(fin,zz);
double a[2],b[2];
fin>>a[0]>>a[1];
cout<
// Now problem begins!
getline(fin,zz1);
fin>>b[0]>>b[1];
cout<
}
Could you explain this t |
|
s*****n 发帖数: 1279 | 21 Both try1.cpp and try2.cpp can be complied, but only try1.cpp works. when I
run try2.cpp, I always got "Segmentation fault". So what is wrong with try2
.cpp? why I can't use ifstream pointer? Thank you!
try1.cpp
#include
#include
#include
using namespace std;
int main()
{
ifstream gains("coeff.txt");
if (!gains.is_open())
{
cout<<"coeff.txt could not be opened! " <
}
else{
cout<<"coeff.txt is open"<
}
return |
|
p**e 发帖数: 533 | 22 #include
main()
{
ifstream in("FileStreamTest.cpp");
while (in.get(*cout.rdbuf()))
in.ignore();
}
这个主要是什么意思?特别是in.get(*cout.rdbuf())这一个怎么解释?谢谢。 |
|
v****c 发帖数: 32 | 23 为啥这种编译过不了?
ifstream in_file;
ofstream out_file;
in_file("data.txt");
out_file("data.sort");
必须得:
ifstream in_file("data.txt");
ofstream out_file("data.sort"); |
|
|
v****c 发帖数: 32 | 25 第二种没问题;高手给解释一下为什么第一种不成?
谢谢!:) |
|
v****c 发帖数: 32 | 26 第二种没问题;高手给解释一下为什么第一种不成?
谢谢!:) |
|
X****r 发帖数: 3557 | 27 在 ifstream in_file("data.txt"); 里:
ifstream是类型,in_file是变量名,"data.txt"是初始化表达式列表,
也就是创建一个新的名叫in_file,类型为ifstream的变量,并用接受一个const char
*(或者const char*可以自动转换成的类型)的构建函数来初始化这个变量。ifstream
类里有这样一个构建函数,所以编译就可以通过。
在 ifstream in_file; in_file("data.txt"); 里:
前一句是创建一个新的名叫in_file,类型为ifstream的变量,并用不带任何参数的构
建函数来初始化这个变量。ifstream类里也有这样一个构建函数,所以编译也可以通过
。但是后一句是调用operator (),由于ifstream类里没有一个重载operator ()的成员
函数,所以编译就不能通过。 |
|
|
g*********s 发帖数: 1782 | 29 一直用FILE*,最近程序有不少IO问题,暂时用ferror catch。
但是看了一下参考资料,似乎只有零和非零的区别。那如何区分具体的错误类型,比如
磁盘满,进程打开文件过多等?查errno似乎也不行。
fstream提供这些信息吗? |
|
j****i 发帖数: 305 | 30 I have a sample file and I could get it to compile.
code:
/////////1/////////2/////////3/////////4/////////5/////////6/////////7//////
///8
// demo.cpp
//
// (C) Copyright 2002-4 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include
#include
#include
#include
#include |
|
s*********x 发帖数: 1923 | 31 c++高手帮帮忙,有一个文件
A01 B01 (13,30,50) (20, 40, 60)
A02 B02 (13,30,50, 100, 200) (20, 40, 60, 105, 206)
我需要读出每行中的每一pair, 比如 (13, 20), (30, 40), (50, 60), 可问题是在第
三列和第四列中,我们不知道有几个数字,比如第一行中有3个pair,第二行中有4个
pair.
我现在的方法是定义四个string, a, b, c, d
fstream >> a >> b >> c >> d. then, c = (13,30,50), c++中怎么把这三个数字读出
来(比如像perl里的split function)?谢了。
Update: I solved the problem. Hope it can help others:
inputFile >> tmp >> tmp >> start >> end ;
....
num = strtok (start, ",");
while (num != NULL)
|
|
z**k 发帖数: 629 | 32 能. ::fopen或fstream.open |
|
c**********e 发帖数: 2007 | 33 This is a very simple code. When I use two identical files (copy to get
an identical copy), it always says "NOT identical".
What is wrong? Thanks a lot.
#include
#include
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
ifstream fin1, fin2;
fin1.open(argv[0]);
fin2.open(argv[1]);
char c1, c2;
do {
fin1.get(c1);
fin2.get(c2);
if(c1!=c2) {
cout << "The two files are NOT identical." << endl;
|
|
t****t 发帖数: 6806 | 34 since you used fstream, the open mode is 0 by default. you have to
explicitly say
fout.open("...", ios_base::out);
or alternatively, use
ofstream fout;
fout.open("...");
EDIT: the default open mode is in|out by default. seems it's not stated
on standard, but i guess most implementation will do that. however, if
you specify ios_base::in, and file do not exist, the open will fail anyway. |
|
t****t 发帖数: 6806 | 35 this is optional given fstream is auto variable and will be destructed
automatically. |
|
P********e 发帖数: 2610 | 36 r u sure
this is optional given fstream is auto variable and will be destructed
automatically. |
|
t****t 发帖数: 6806 | 37 you mean &c as A*, B*, C* are all the same? on gcc they are not.
#include
#include
#include
using namespace std;
class A { int a; };
class B { int b; };
class C : public A, public B { int c; };
int main() {
C c;
C *pc=&c;
B *pb=&c;
A* pa=&c;
cout<<"pc="<b***y 发帖数: 2799 | 38 ☆─────────────────────────────────────☆
careerchange (Stupid) 于 (Mon Dec 8 20:34:06 2008) 提到:
Urgent help needed, project due in a couplr of hours.
What is wrong? The following code does not ask the name input:
At running, after I type 3, it prints but does not wait for input.
#include
#include
using namespace std;
int main(){
int nextAction;
cin >> nextAction;
char name[80];
cout << "Please type the name:" << endl;
cin.getline(itemname,80,'\n');
| |
|
g****y 发帖数: 436 | 39 一个cpp文件的头部:
#include "BEDFileData.h"
#include
using namespace std;
using namespace affxbed;
#pragma warning(disable: 4996)
然后中间有用到 strlen之类的函数,比如:
void BEDFileData::FormatTrack(const char *name, const char *desc)
{
char line[256];
if (desc && strlen(desc) > 0)
sprintf(line, "%s\"%s\" description=\"%s\"", TRACK_LINE_
START, name, desc)
;
else
sprintf(line, "%s\"%s\"", TRACK_LINE_START, name);
track=line;
}
编译的时候,报错说:
error: |
|
z****e 发帖数: 2024 | 40 看到thinking in c++一段代码:
#include
#include
using namespace std;
ofstream out("HowMany.out");
class HowMany {
static int objectCount;
public:
HowMany() { objectCount++; }
static void print(const string& msg = "") {
if(msg.size() != 0) out << msg << ": ";
out << "objectCount = "
<< objectCount << endl;
}
~HowMany() {
objectCount--;
print("~HowMany()");
}
};
int HowMany::objectCount = 0;
HowMany f(HowMany x) {
x.print("x argument inside f()");
return x;
} |
|
a********n 发帖数: 648 | 41 下面这个简单程序,我创建一个文件并在里面存了8个数,10,20,...,80,然后需要从
第三个数起读2个数,应该是30,40。但是读出来却是7680,10240,不知道是不是
seekg()这个函数没有用对,折腾了很久,还是不对,不知道哪位大牛可以帮着看看。
谢谢了先。
int main()
{
int i, k;
//Create a file
fstream OUTPUT( "RESULT.dat", ios::out | ios::in );
if( !OUTPUT )
{
cerr << "File could not be opened." << endl;
exit( 1 );
}
//Input the data
for( i=1; i<=8; i++ )
{
k = i*10;
cout << " k = " << k << endl;
OUTPUT.write( reinterpret_cast |
|
z****e 发帖数: 2024 | 42 #include
#include
ifstream inf("your_file_wants_to_be_read.txt");//source file
vector vs((istream_iterator(inf)),
istream_iterator());//read into string vector
for the second sentence, pay attention, do not be fooled by the "most vexing
parse of C++",
else you will only define a function rather than a vector. |
|
w***g 发帖数: 5958 | 43 我觉得mmap并不一定总是能加速,要具体问题具体分析。我觉得大部分情况下即使能加
速,得到的那一点点提高也比不上FILE*和fstream的可移植性。 |
|
D******4 发帖数: 47 | 44 今天看到dynamic memory,测试如下程序:
#include
#include
#include
using namespace std;
ifstream fin("test.in");
ofstream fout("test.out");
int main (){
int i = 0;
int n = 0;
int* p;
if(fin.is_open()){
fin>>n;
fout<<"n is: "<
p = new (nothrow) int[n];
if (p == 0)
fout << "Error: memory could not be allocated"<
else{
for (i=0; i> p[i];
fin.close();
fout << "You have ent |
|
M*******r 发帖数: 165 | 45 【 以下文字转载自 Quant 讨论区 】
发信人: Morphiner (Ninja Turtle), 信区: Quant
标 题: 借人气问个c++的overflow
发信站: BBS 未名空间站 (Mon Nov 15 12:40:52 2010, 美东)
stack overflow在main后面的{
会是怎么回事?
附上code:
//#include
#include
#include
#include
#include "BarGame.h"
#include
#include
//#include "randomc.h"
//#include "mersenne.cpp" // code for random number generator of
type Mersenne twister
#include "require.h"
//#inclu... 阅读全帖 |
|
b********r 发帖数: 1080 | 46 【 以下文字转载自 Computation 讨论区 】
发信人: bankbuster (恭喜发财), 信区: Computation
标 题: C++里用Blas/Lapack的问题
发信站: BBS 未名空间站 (Tue Aug 9 14:57:49 2011, 美东)
我用atlas,程序里简单调用zgeev函数。编译没有错,没有警告。运行也不出错,但结
果完全不对。似乎函数根本没有被调用。
另外哪里能找到在C或者C++下调用Blas/Lapack函数的具体格式?我这里函数参数还是
在网上搜的。完全没有相关的手册。难道Blas/Lapack只是给fortran用的?
程序如下
#include
#include
#include
#include
#include
using namespace std;
typedef complex dcomplex;
extern "C" void zgeev_( char* jobvl, char* jobvr, int* n, ... 阅读全帖 |
|
c**********e 发帖数: 2007 | 47 【 以下文字转载自 JobHunting 讨论区 】
发信人: careerchange (Stupid), 信区: JobHunting
标 题: C++ Q 99-102
发信站: BBS 未名空间站 (Fri Oct 28 23:14:06 2011, 美东)
C++ Q 99: global and static
What type of linkage does global variables and functions preceded by
the storage class specifier static have?
a. Internal
b. Intern
c. External
d. Extern
Answer: a
C++ Q 100: directives
Any number of which of the following directives can appear between
the #if and #endif directives?
a. #elif
b. #endif
c. #else
d. #if
Answer: a
C++ Q101... 阅读全帖 |
|
t****t 发帖数: 6806 | 48 in c++03 only accept const char* as filename, so it's normal peopl
e use const char*. if you use string, you will have to write
file.open(fname.c_str());
which is kind of ugly. c++11 fixed this problem, so you can use string now. |
|
d**********u 发帖数: 3371 | 49 看了一下 好想只能用
std::ifstream *fs;
作为类成员 否则报错
是什么原因呢 |
|
|