i don't know how to do this without using an array in which i've already copied the information from the text file ..i mean, to me handling arrays is a very easy thing but i get confused with files ...
so here's the code...
Code:
#include <fstream.h>
#include<conio.h>
unsigned long int nr;
char a[1000000];
void main(){
ifstream f("nrbinar.in", ios::in);
while(f.getline(a,1000000)){
if (strcmp(a,"0")==0) nr+=nr;
if(strcmp(a,"1")==0) nr=0; }
cout<<nr;
getch();
}
well i thought i'd reed the succsesive "0" and "1" s and when i found a "0" i would increment the counter... and so on ..and if i got a "1" after this succsession then i'd make the counter n=0 again because that succesion of zeros i've just counted wasn't formed out of the "zeros" i searched for ...i know i'm doing something wrong cuz i never get to looking at the next character from the file *worried*