fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <fstream>
  5. #include <cmath>
  6. #include <cstdlib>
  7. #include <sstream>
  8.  
  9. int main(int argc, char* argv[])
  10. {;
  11. int arraylen = 7, arraylen_new = 0;
  12. string line, field, junkText;
  13. string* randNum = new string[arraylen];
  14. string* phrase = new string[arraylen];
  15.  
  16. ifstream randomTxt;
  17. i= 0;
  18. arraylen = 5;
  19.  
  20. randomTxt.open("random.txt");
  21.  
  22. while(!randomTxt.eof())
  23. {
  24. getline(randomTxt,line);
  25. stringstream ss(line);
  26. nextstep = 0;
  27. while(getline(ss,field,','))
  28. {
  29. cout << i << endl;
  30. /*if(nextstep == 0)
  31.   {
  32.   randNum[i] = field;
  33.   cout<< "number " << i << ": " << randNum[i] << endl;
  34.   nextstep = 1;
  35.   }
  36.  
  37.   else if(nextstep == 1)
  38.   {
  39.   junkText = field;
  40.   cout<< "junk " << i << ": " << junkText << endl;
  41.   nextstep = 2;
  42.   }
  43.   else
  44.   {
  45.   items[i] = field;
  46.   cout<< "items " << i << ": " << items[i] << endl;
  47.   }*/
  48.  
  49. if(i == (arraylen-1))
  50. {
  51. arraylen_new = arraylen + 1;
  52. string* temp1 = new string[arraylen_new];
  53. string* temp2 = new string[arraylen_new];
  54. copy(randNum, (randNum+arraylen), temp1);
  55. delete [] UPCsale;
  56. randNum = temp1;
  57.  
  58. copy(phrase, (phrase + arraylen), temp2);
  59. delete [] phrase;
  60. phrase = temp2;
  61. arraylen = arraylen_new;
  62. }
  63. }
  64. cout<<"test"<<endl;
  65. i++;
  66.  
  67. }
  68. sales.close();
  69.  
  70. /*for(int i = 0; i < arraylen;i++)
  71.   {
  72.   cout<< "UPC " << i << ": " << UPC[i] << "\t" << "Phrase " << i << ": " << phrase[i] << endl;
  73.  
  74.   }*/
  75.  
  76. return 0;
  77. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main(int, char**)':
prog.cpp:12:5: error: 'string' was not declared in this scope
     string line, field, junkText;
     ^
prog.cpp:12:5: note: suggested alternative:
In file included from /usr/include/c++/4.9/iosfwd:39:0,
                 from /usr/include/c++/4.9/ios:38,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/stringfwd.h:62:33: note:   'std::string'
   typedef basic_string<char>    string;   
                                 ^
prog.cpp:13:13: error: 'randNum' was not declared in this scope
     string* randNum = new string[arraylen];
             ^
prog.cpp:13:27: error: 'string' does not name a type
     string* randNum = new string[arraylen];
                           ^
prog.cpp:14:13: error: 'phrase' was not declared in this scope
     string* phrase = new string[arraylen];
             ^
prog.cpp:14:26: error: 'string' does not name a type
     string* phrase = new string[arraylen];
                          ^
prog.cpp:16:5: error: 'ifstream' was not declared in this scope
     ifstream randomTxt;
     ^
prog.cpp:16:5: note: suggested alternative:
In file included from /usr/include/c++/4.9/ios:38:0,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/iosfwd:157:34: note:   'std::ifstream'
   typedef basic_ifstream<char>   ifstream;
                                  ^
prog.cpp:17:5: error: 'i' was not declared in this scope
     i= 0;
     ^
prog.cpp:20:5: error: 'randomTxt' was not declared in this scope
     randomTxt.open("random.txt");
     ^
prog.cpp:24:27: error: 'line' was not declared in this scope
         getline(randomTxt,line);
                           ^
prog.cpp:25:9: error: 'stringstream' was not declared in this scope
         stringstream ss(line);
         ^
prog.cpp:25:9: note: suggested alternative:
In file included from /usr/include/c++/4.9/ios:38:0,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/iosfwd:151:37: note:   'std::stringstream'
   typedef basic_stringstream<char>  stringstream;
                                     ^
prog.cpp:26:9: error: 'nextstep' was not declared in this scope
         nextstep = 0;
         ^
prog.cpp:27:23: error: 'ss' was not declared in this scope
         while(getline(ss,field,','))
                       ^
prog.cpp:27:26: error: 'field' was not declared in this scope
         while(getline(ss,field,','))
                          ^
prog.cpp:29:13: error: 'cout' was not declared in this scope
             cout << i << endl;
             ^
prog.cpp:29:13: note: suggested alternative:
In file included from prog.cpp:1:0:
/usr/include/c++/4.9/iostream:61:18: note:   'std::cout'
   extern ostream cout;  /// Linked to standard output
                  ^
prog.cpp:29:26: error: 'endl' was not declared in this scope
             cout << i << endl;
                          ^
prog.cpp:29:26: note: suggested alternative:
In file included from /usr/include/c++/4.9/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/4.9/ostream:564:5: note:   'std::endl'
     endl(basic_ostream<_CharT, _Traits>& __os)
     ^
prog.cpp:52:25: error: 'temp1' was not declared in this scope
                 string* temp1 = new string[arraylen_new];
                         ^
prog.cpp:52:37: error: 'string' does not name a type
                 string* temp1 = new string[arraylen_new];
                                     ^
prog.cpp:53:25: error: 'temp2' was not declared in this scope
                 string* temp2 = new string[arraylen_new];
                         ^
prog.cpp:53:37: error: 'string' does not name a type
                 string* temp2 = new string[arraylen_new];
                                     ^
prog.cpp:54:56: error: 'copy' was not declared in this scope
                 copy(randNum, (randNum+arraylen), temp1);
                                                        ^
prog.cpp:54:56: note: suggested alternative:
In file included from /usr/include/c++/4.9/bits/locale_facets.h:48:0,
                 from /usr/include/c++/4.9/bits/basic_ios.h:37,
                 from /usr/include/c++/4.9/ios:44,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/streambuf_iterator.h:293:5: note:   'std::copy'
     copy(istreambuf_iterator<_CharT> __first,
     ^
prog.cpp:55:27: error: 'UPCsale' was not declared in this scope
                 delete [] UPCsale;
                           ^
prog.cpp:59:27: error: type '<type error>' argument given to 'delete', expected pointer
                 delete [] phrase;
                           ^
prog.cpp:64:9: error: 'cout' was not declared in this scope
         cout<<"test"<<endl;
         ^
prog.cpp:64:9: note: suggested alternative:
In file included from prog.cpp:1:0:
/usr/include/c++/4.9/iostream:61:18: note:   'std::cout'
   extern ostream cout;  /// Linked to standard output
                  ^
prog.cpp:64:23: error: 'endl' was not declared in this scope
         cout<<"test"<<endl;
                       ^
prog.cpp:64:23: note: suggested alternative:
In file included from /usr/include/c++/4.9/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/4.9/ostream:564:5: note:   'std::endl'
     endl(basic_ostream<_CharT, _Traits>& __os)
     ^
prog.cpp:68:5: error: 'sales' was not declared in this scope
     sales.close();
     ^
stdout
Standard output is empty