View Single Post
Join Date: May 2008
Posts: 99
Reputation: FTProtocol has a little shameless behaviour in the past 
Solved Threads: 1
FTProtocol FTProtocol is offline Offline
Junior Poster in Training

Re: find string in txt file

 
0
  #6
Dec 2nd, 2008
oh it works

  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. char szUser[50], szPass[50];
  7. bool bFound = false;
  8.  
  9. void GetUser(string szInput)
  10. {
  11. const char *szUserBuffer;
  12.  
  13. std::string szTemp = szInput;
  14. szUserBuffer = szTemp.c_str();
  15. sprintf(szUser, "%s", szUserBuffer);
  16.  
  17. for (int i = strlen(szUser) + 1; i > 0; i--)
  18. {
  19. if( szUser[i] == ':')
  20. {
  21. strcpy(szUser, &szUser[i + 2]);
  22. break;
  23. }
  24. }
  25. }
  26.  
  27. void GetPassword(string szInput)
  28. {
  29. const char *szPassBuffer;
  30.  
  31. std::string szTemp = szInput;
  32. szPassBuffer = szTemp.c_str();
  33. sprintf(szPass, "%s", szPassBuffer);
  34.  
  35. for (int t = strlen(szPass) + 1; t > 0; t--)
  36. {
  37. if( szPass[t] == ':')
  38. {
  39. strcpy(szPass, &szPass[t + 2]);
  40. break;
  41. }
  42. }
  43. }
  44.  
  45. int main()
  46. {
  47. ifstream RapidShit ("C:\\Rapid.txt");
  48. string ****Nipples;
  49.  
  50. if(RapidShit.is_open())
  51. {
  52. while (!bFound)
  53. {
  54. getline(RapidShit, ****Nipples);
  55. if(****Nipples == "https://ssl.rapidshare.com")
  56. {
  57. getline(RapidShit, ****Nipples);
  58. getline(RapidShit, ****Nipples);
  59. GetUser(****Nipples);
  60. getline(RapidShit, ****Nipples);
  61. GetPassword(****Nipples);
  62. bFound = true;
  63. }
  64. }
  65. }
  66. cin.get();
  67. return 0;
  68. }

Probably far too long but it works.
Reply With Quote