473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

while reading a text file which contains repetitive 0,1 and 2 using fgetc ....

in the following code i am trying to read a file containing 0,1,2 patterns, on running it fails and shows that binary.exe file failed. can anyone suggest :



#include<stdio.h>
#include<iostream>
#include<conio.h>
using namespace std;


int main()
{
//clrscr();
int a[5000][1],t=0,tb=0,tn=0,w=0,tn1=0,z=0,fn=6,x=0,d=0,v;
int i,n,p[10][1]={3,3,3,3,3,3,3,3,3,3},j=0,k=0,m=0,l[3][1]={1,1,0},s[5000][1],r=0,bn[10][1],b=0,f=0,result[1000][1] ;

for(i=0;i<100;i++)
{
result[i][0]=4;
}
for (i=0;i<=1000;i++)
{ a[i][0]=5; } // input array is filled with 5

FILE *fp;
char ch ;

fp = fopen( "d:\\test file \\test1.txt","r") ;

label1: while(1)
{
ch= fgetc(fp);
//printf("%c \n",ch);

if (ch== EOF)
break;
if (ch==' ')
{ goto label1; }
a[z][0]=ch; // input array is filled with the characters of the file

printf("%c ",a[z][0]);
z++;
}
w=z;

printf ("\n number of bits= %d\n",w) ;

fclose (fp) ;

getch();

}
Aug 22 '15 #1
0 1093

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: fabrice | last post by:
Hello, I've got trouble reading a text file (event viewer dump) by using the getline() function... After 200 - 300 lines that are read correctly, it suddenly stops reading the rest of the...
8
by: Phil Slater | last post by:
I'm trying to process a collection of text files, reading word by word. The program run hangs whenever it encounters a word with an accented letter (like rôle or passé) - ie something that's not a...
7
by: Drew Berkemeyer | last post by:
Hello, I'm using the following code to read a text file in VB.NET. Dim sr As StreamReader = File.OpenText(strFilePath) Dim input As String = sr.ReadLine() While Not input Is Nothing...
4
by: Volker Jobst | last post by:
Hi, Is there a really fast way to read a text file which contains lines of variable length? I'm using the StreamReader to read the file, but this is not as fast as I need it. thanks a lot...
4
by: Amit Maheshwari | last post by:
I need to read text file having data either comma seperated or tab seperated or any custom seperator and convert into a DataSet in C# . I tried Microsoft Text Driver and Microsoft.Jet.OLEDB.4.0...
1
by: John | last post by:
I have a process that reads a text file then uploads the data into a database table. The text file has 10 lines at the end of the file that are blank BUT it appears that the enter key or space bar...
2
by: jatindersingh80 | last post by:
Hi , i am reading a text file with token # but somtimes blank lines comes between the line at blank line the code gives exception of no such element the text files contains data after blank lines...
3
by: jasvinder singh | last post by:
Respected Sir/madam, Can you help in providing code in 'C' for Reading text file with n number of rows and columns and putting the result in arrays.The sample file is as follows: rim_label =...
1
by: paulnamroud | last post by:
Hi Guys, I have a weird problem. While reading my csv file some data a returned as null. When the routine reads values in the column "Size_Code" (like "S",, "M"...) it returns "NULL". When...
1
by: spiralfire | last post by:
I'm writing a parser, and im totally confused. Its apparently correct, but something is happening: I do a fread command to a char array of the entire file (it isn't big), this is the file: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.