fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <fstream>
  4.  
  5. std::vector<float>vfdata;
  6. int inumber=0;
  7. int t_1=0;
  8.  
  9. void write(void);
  10.  
  11. void main()
  12. {
  13. read(pipe1[0], & smsg, sizeof(S_DATA));
  14. inumber=smsg.data[0];
  15.  
  16. while (1){
  17. read(pipe1[0], & smsg, sizeof(S_DATA));
  18.  
  19. if(smsg.data[0]){
  20. vfdata.push_back(smsg.data[1]);
  21. vfdata.push_back(smsg.data[2]);
  22. vfdata.push_back(smsg.data[3]);
  23. vfdata.push_back(smsg.data[4]);
  24. vfdata.push_back(smsg.data[5]);
  25. t_1++;
  26. }
  27. if(t_1==inumber){
  28. write();
  29. }
  30. }
  31.  
  32. }
  33.  
  34. void write(void)
  35. {
  36. ofstream write(" Path/Data.txt", std::ofstream::app);
  37. if (write.is_open()){
  38. for (int i=0; i<vfdata.size(); i++){
  39. write<<vfdata[i];
  40. }
  41. write.close();
  42. }
  43.  
  44. void write(void);
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:11:11: error: ‘::main’ must return ‘int’
 void main()
           ^
prog.cpp: In function ‘int main()’:
prog.cpp:13:8: error: ‘pipe1’ was not declared in this scope
   read(pipe1[0], & smsg, sizeof(S_DATA));
        ^
prog.cpp:13:20: error: ‘smsg’ was not declared in this scope
   read(pipe1[0], & smsg, sizeof(S_DATA));
                    ^
prog.cpp:13:33: error: ‘S_DATA’ was not declared in this scope
   read(pipe1[0], & smsg, sizeof(S_DATA));
                                 ^
prog.cpp:13:40: error: ‘read’ was not declared in this scope
   read(pipe1[0], & smsg, sizeof(S_DATA));
                                        ^
prog.cpp: In function ‘void write()’:
prog.cpp:36:3: error: ‘ofstream’ was not declared in this scope
   ofstream write(" Path/Data.txt", std::ofstream::app);
   ^
prog.cpp:36:3: note: suggested alternative:
In file included from /usr/include/c++/4.8/ios:38:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/iosfwd:160:34: note:   ‘std::ofstream’
   typedef basic_ofstream<char>   ofstream;
                                  ^
prog.cpp:36:12: error: expected ‘;’ before ‘write’
   ofstream write(" Path/Data.txt", std::ofstream::app);
            ^
prog.cpp:37:13: error: request for member ‘is_open’ in ‘write’, which is of non-class type ‘void()’
   if (write.is_open()){
             ^
prog.cpp:38:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<vfdata.size(); i++){
                                 ^
prog.cpp:39:22: error: invalid operands of types ‘void()’ and ‘__gnu_cxx::__alloc_traits<std::allocator<float> >::value_type {aka float}’ to binary ‘operator<<’
       write<<vfdata[i];
                      ^
prog.cpp:41:11: error: request for member ‘close’ in ‘write’, which is of non-class type ‘void()’
     write.close(); 
           ^
prog.cpp:44:17: error: expected ‘}’ at end of input
 void write(void);
                 ^
stdout
Standard output is empty