![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2005
Posts: 18
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
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 |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Mar 2005
Posts: 18
Rep Power: 0
![]() |
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? |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2005
Posts: 89
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Feb 2005
Posts: 89
Rep Power: 4
![]() |
i stand corrected. apparently the new IrDA can transfer at 4 Mb/s.
|
|
|
|
|
|
#6 |
|
Newbie
Join Date: Mar 2005
Posts: 18
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#7 |
|
Programmer
Join Date: Feb 2005
Posts: 89
Rep Power: 4
![]() |
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.
|
|
|
|
|
|
#8 |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4
![]() |
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. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|