fork download
  1. /*search.cpp*/
  2.  
  3. #include <iostream>
  4. #include <fstream>
  5. #include <string>
  6. #include <cstdlib>
  7.  
  8. using namespace std;
  9.  
  10.  
  11. int GetFileStats(string filename, string& firstKey, string& firstValue)
  12.  
  13. {
  14. int N=0;
  15. ifstream f;
  16. char*dd;
  17. dd=&filename[0];
  18. f.open(dd);
  19. if(f.is_open())
  20. cout<<"#";
  21. else
  22. exit(0);
  23. int i=0;
  24. while(!f.eof())
  25. {
  26. string str;string value;
  27. f>>value>>str;
  28. if(str.length()!=0)
  29. N++;
  30. if(i==0)
  31. {
  32. firstKey.assign(str);
  33. firstValue.assign(value);
  34. }
  35. i++;
  36. }
  37. f.close();
  38.  
  39. return N;
  40. }
  41.  
  42.  
  43. bool SearchForKey(string filename, string key, string& value, int& rank)
  44. {
  45. string str;string n;int i=0;bool found;
  46. ifstream f;
  47. char*dd;
  48. dd=&filename[0];
  49. f.open(dd);
  50. while(!f.eof())
  51. {
  52. f>>n>>str;
  53. if(str==key){
  54. value=n;
  55. rank=i+1;
  56. //rank=i+1;
  57. break;
  58. }
  59. i++;
  60. }
  61. if(f.eof())
  62. found=false;
  63. else
  64. found=true;
  65.  
  66.  
  67.  
  68. return found;
  69. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty