Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 20th, 2006, 7:32 PM   #1
hbe02
Hobbyist Programmer
 
hbe02's Avatar
 
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3 hbe02 is on a distinguished road
input output streaming

I edited and used following code from an internet source. im having trouble with the commented line (TBitstream=fgetc(fp). aparently fgetc is used for integers. what should i type instead to cin.getline(Tbitstream)..


cout<<"Enter Filename To Input Bitstream From: ";
char * filename = new char [100];
FILE *fp;
gets(filename);
if((fp=fopen(filename,"rb"))==NULL)
{
cout<<"FILE DOES NOT EXIST"<<endl;
exit(1);
}
char * TBitstream = new char [2000];
//TBitstream=fgetc(fp);
fclose(fp);
hbe02 is offline   Reply With Quote
Old Mar 20th, 2006, 7:32 PM   #2
hbe02
Hobbyist Programmer
 
hbe02's Avatar
 
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3 hbe02 is on a distinguished road
forgot to say thanks
hbe02 is offline   Reply With Quote
Old Mar 20th, 2006, 8:02 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Try reading your docs. Makes a helluva difference. fgetc returns an integer representing a character or status. Since you're programming C++, you might want to explore C++ mechanisms, also.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 20th, 2006, 9:06 PM   #4
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 894
Rep Power: 4 The Dark is on a distinguished road
If you want to read a line, use fgets. If you want to read some binary data, use fread.
The Dark is offline   Reply With Quote
Old Mar 20th, 2006, 9:12 PM   #5
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3 Jimbo is on a distinguished road
Quote:
Originally Posted by The Dark
If you want to read a line, use fgets. If you want to read some binary data, use fread.
Quote:
Originally Posted by DaWei
Since you're programming C++, you might want to explore C++ mechanisms, also.
How about looking into fstreams...
Jimbo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:40 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC