Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to check size of file in c++

#include <fstream>

std::ifstream::pos_type filesize(const char* filename)
{
    std::ifstream in(filename, std::ifstream::ate | std::ifstream::binary);
    return in.tellg(); 
}
Comment

how to get length of a file in c++

#include <iostream>
#include <fstream>

using namespace std;

int main()
{

  ifstream hin("<file_name>.txt");
  string cont[31];// There are 31 lines in this file

  for (int i = 0; i < 32; i++)
  {
    hin >> cont[i];
    cout << i<<" " << cont[i]<<endl;
  }


  return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ loop through string 
Cpp :: built in led 
Cpp :: how to run a msi file raspbrain 
Cpp :: c++ measure time in microseconds 
Cpp :: c++ compare time 
Cpp :: syntax c++ 
Cpp :: change to lowercase in notepad++ 
Cpp :: chrono library c++ 
Cpp :: array and for loop in c++ 
Cpp :: take pieces of a string in c++ 
Cpp :: substring to int c++ 
Cpp :: Rick Astley - Never Gonna Give You Up 
Cpp :: c++ check if vector is sorted 
Cpp :: c++ reading string 
Cpp :: const char to string 
Cpp :: how to get an element in a list c++ 
Cpp :: c++ find_if 
Cpp :: overload stream insert cpp 
Cpp :: remove element from array c++ 
Cpp :: get value of enum cpp 
Cpp :: c++ binary search 
Cpp :: C++ String Copy Example 
Cpp :: c++ fstream 
Cpp :: why is using namespace std a bad practice 
Cpp :: string to integer in c++ 
Cpp :: c++ casting 
Cpp :: iterate through map c++ 
Cpp :: Palindrome String solution in c++ 
Cpp :: C++ fill string with random uppercase letters 
Cpp :: notepad++ 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =