apl-mhd

file read write

Jul 30th, 2019
163
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <cstring>
  4. #include <string>
  5. #include <iostream>
  6. using  namespace std;
  7. int main()
  8. {
  9.  
  10.     FILE *inFile, *readFile;
  11.  
  12.     char name[100];
  13.  
  14.     /*inFile = fopen("infile.txt", "w");
  15.  
  16.     fprintf(inFile, "%s\n", "Orko");
  17.  
  18.     fclose(inFile);
  19. */
  20.  
  21.     readFile = fopen("infile.txt", "r");
  22.     fscanf(readFile, "%s", name);
  23.  
  24.  
  25.     int i=0;
  26.     while(name[i] != '\0'){
  27.  
  28.         i++;
  29.     }
  30.     cout<<i<<endl;
  31.  
  32.  
  33.     return 0;
  34. }
RAW Paste Data