- 论坛徽章:
- 0
|
#include <iostream>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include <fcntl.h>
5 #include <unistd.h>
6 using namespace std;
7
8 int main(){
9 int fd = open( "some.txt",O_WRONLY|O_CREAT,0700 );
10 if( fd<0 ){
11 cout << "open error " << endl;
12 return ;
13 }
14 char buf[100];
15 do{
16 cin.ignore( 255,'\n' );
17 memset( buf,0,100 );
18 cin.getline( buf,100 );
19 int size = write( fd, buf, 99 );
20 if( size<0 || buf=="exit" )
21 break;
22 }while( 1 );
23 close( fd );
24
25
26
27
28 return 0;
29 }
报错如下:
write_example.cc: In function `int main()':
write_example.cc:12: return-statement with no value, in function declared with
a non-void return type |
|