fstream, two dimensional arrays and spaces

Hello, I'm trying to get fstream to send words seperated by spaces (or tabs) into a two dimensional array (ie: one dimension for the word itself, one for distinguishing words). But... nothing I've tried seems to work. The problem is that I cannot find a way to make spaces/tabs in the input text cause an increment in the value of "j". Hell I can't get it to recognize spaces.

This is for an assignment with no strings allowed, only fstream and iostream. Any help would be appreciated.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <fstream>
#include <iostream>
using namespace std;

int main()
{
char chaine[300][25];
ifstream entree("dico.txt"); 
int i=0,j=0;

while (!entree.eof()) 
{
i++;
entree >> chaine[i][j];

//lacks a way of recognizing tabs/white spaces and trigerring j++ after one.
} 


entree.close(); 

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
int main()
{
char chaine[300][25];
ifstream entree("dico.txt"); 
int i=0,j=0;

while (!entree.eof()) 
{

entree >> chaine[i];


i++;
//lacks a way of recognizing tabs/white spaces and trigerring j++ after one.
} 


entree.close(); 

}


see if that works.. and if this is what you want.
Topic archived. No new replies allowed.