I get segmentation file in the below code. The reason is in the line 10 I guess where I'm using char* buffer. I want to know why is this.
Is it because the memory in the buffer is not still allocated?
Here is the code:
  1 #include <iostream>
  2 #include <fstream>
  3
  4 int main()
  5 {
  6     const char* filename = "directory of my file";// mnt/c/Users/...
  7     std::fstream fin(filename,std::fstream::in);
  8     if(!fin.is_open())
  9         std::cout << "Opps!" << std::endl;
 10     char* buffer = NULL;//if char buffer[100] then it will be good.
 11     while(!fin.eof())
 12     {
 13         fin.getline(buffer,100);
 14         std::cout << buffer << std::endl;
 15     }
 16     return 0;
 17 }
 
    