SHARE
TWEET

Untitled

a guest Dec 16th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string.h>
  4. using namespace std;
  5. int transfromation (char sir[3]){
  6.     int i, number;
  7.     number = sir[0]-48;
  8.     for(i = 1; i< strlen(sir); i++){
  9.         number = number * 10 + (sir[i]-48);
  10.  
  11.     }
  12.     cout<<"the number = "<<number;
  13.     return number;
  14. }
  15. int main()
  16. {   char curent[20];
  17.     char* products = new char[20];
  18.     int price[20];
  19.     int i, j, p = 0, index_price = 0, index_products = 0;
  20.     char pretul_char[10];
  21.     char numele_produsului[20];
  22.  
  23.  
  24.  
  25.     ifstream f ("products.txt");
  26.     ofstream l ("less.txt");
  27.     ofstream m ("more.txt");
  28.  
  29.     while(f.getline(curent,20)){
  30.             for(i = 0; i < strlen(curent); i++){
  31.                 if(curent[i] != ','){
  32.                     numele_produsului[i] = curent[i];
  33.                 }
  34.                 else break;
  35.             }
  36.             for (j = i + 1; j < strlen(curent); j++){
  37.                 pretul_char[p] = curent[j];
  38.                 p++;
  39.             }
  40.             price[index_price] = transformation(pretul_char);
  41.             index_price++;
  42.             strcpy(products[index_products], numele_produsului);
  43.  
  44.             index_products++;
  45.  
  46.             p = 0;
  47.             i = 0;
  48.             j = 0;
  49.  
  50.     }
  51.  
  52.  
  53.  
  54.     f.close();
  55.     l.close();
  56.     m.close();
  57.     return 0;
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top