Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Mar 28th, 2005, 2:12 PM   #1
freddielj
Newbie
 
Join Date: Mar 2005
Posts: 18
Rep Power: 0 freddielj is on a distinguished road
the stdio lib

i am trying to create pointers of type FILE to text documents for a project and am using code as follows

FILE *BernardoBellotto;
BernardoBellotto = &BernardoBellotto.txt;

i am very rusty and getting errors i can't seem to resolve like
C:\Documents and Settings\Freddie\My Documents\FYP\files.c(18) : error C2039: 'txt' : is not a member of '_iobuf'
c:\program files\microsoft visual studio\vc98\include\stdio.h(146) : see declaration of '_iobuf'

which doesn't give me any idea how to go around this. i have to deliver this project in the next week so any help would be great
thanks
Freddie
freddielj is offline   Reply With Quote
Old Mar 28th, 2005, 2:55 PM   #2
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
I think what you're trying to do is this:

 FILE *BernardoBellotto;
 
 BernardoBellotto = fopen("BernardoBellotto.txt", "r");

And of course the r could be replaced by w for writing, a for appending, and there are other options as well.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Mar 28th, 2005, 3:03 PM   #3
freddielj
Newbie
 
Join Date: Mar 2005
Posts: 18
Rep Power: 0 freddielj is on a distinguished road
Mjordan2nd,
thanks man but what i need to do is send a file via an ifrared port so i need to send the file into the buffer, and the has got to be a quicker way than opening the file and using fgets and fputs? any suggestions?
freddielj is offline   Reply With Quote
Old Mar 28th, 2005, 3:13 PM   #4
brkstf
Programmer
 
brkstf's Avatar
 
Join Date: Feb 2005
Posts: 89
Rep Power: 4 brkstf is on a distinguished road
well, the first error is kinda obvious. it thinks you want to access a data object using the c++ dot(.) operator. and the iobuf object definition doesn't have a "txt" member.

error two is a result of error one.

quotation marks needed with different syntax.

also, what's the problem with using fget and fput to load the file into a buffer. your hard disk is going to be WAY faster than your infrared port. i doubt that you can transfer anywhere near 6 or 7 megs/second, which is pretty normal for a hard drive.
brkstf is offline   Reply With Quote
Old Mar 28th, 2005, 3:17 PM   #5
brkstf
Programmer
 
brkstf's Avatar
 
Join Date: Feb 2005
Posts: 89
Rep Power: 4 brkstf is on a distinguished road
i stand corrected. apparently the new IrDA can transfer at 4 Mb/s.
brkstf is offline   Reply With Quote
Old Mar 28th, 2005, 3:23 PM   #6
freddielj
Newbie
 
Join Date: Mar 2005
Posts: 18
Rep Power: 0 freddielj is on a distinguished road
transfering it piece by piece means i have to reform the file in the IR buffer for the driver to send it using the protocols it uses. plus the files are like 6k in size as there are WML format well they will be once i change them.

i just want to have points to these files to assosiate to the driver and let the driver call the pointers to transfer the file accross to a mobile phone. so should i just keep the strings of the file names int he pointer and open them as needed?

thanks for the help by the way
freddielj is offline   Reply With Quote
Old Mar 28th, 2005, 3:35 PM   #7
brkstf
Programmer
 
brkstf's Avatar
 
Join Date: Feb 2005
Posts: 89
Rep Power: 4 brkstf is on a distinguished road
wish i could help you more. i just don't know enough about the File object you're using. presumably your API documentation for your mobile has detailed instructions for this. i wouldn't be surprised if the code is already written and available to developers.
brkstf is offline   Reply With Quote
Old Mar 31st, 2005, 10:17 AM   #8
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4 mackenga is on a distinguished road
The only thing faster for file I/O (and it's only marginally faster, depending on how you use it and various system dependant factors) is to call open() rather than fopen(). This gives you an integer file descriptor rather than a FILE *, which you can give as an argument to read() rather than fgets(). Close these int descritors with close().

This should be a little quicker because while fgets() and friends are library functions, open(), read(), creat(), close(), etc., are system calls right into the kernel. fgets() will actually call read() at some point (no other way to read data) but will do other processing, e.g. translations as well which in this case you probably don't want.
mackenga 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:18 AM.

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