My text file contents are in the form "00101010111101101011".

I want to read it from the file and send each digit to an array,unfortunately i'm only able to use char while reading a file.How do i send each digit onto an array?a

#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <string>
#include <cstdlib>



using namespace std;
             
int main()
{
    
char st[32];
int y[32]={0},n=0;
int fstd=0;

ifstream std;
  
 
std.open("std.txt");
if(std.is_open())
{
    std.seekg(0, ios::end ); 
    fstd = std.tellg();
}

 std.read(st,fstd);
 std >> st[n];
 n++;
 std.close();
 cout <<endl;
 
 
 for(int i=0;i<=fstd;i++){  
 y= (unsigned char) st[i];        
 cout << st[i] << " ";
 }

  
  cin.get();
  return 0;
 
}

Here's what I see:

std.open("std.txt");
   if(std.is_open())            // Why are you doing this?
   {                        
       std.seekg(0, ios::end ); // Jump to bottom of file
       fstd = std.tellg();  
   }
    
    // If open failed, why are you trying to read?
    std.read(st,fstd);    // You've jumped to the end of the file
    std >> st[n];         // -- there is nothing there to read
    n++;
    std.close();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.