LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-20-2006, 08:59 AM   #1
andystanfordjason
Member
 
Registered: Oct 2006
Location: england
Distribution: fedora 6
Posts: 38

Rep: Reputation: 15
using fread with fscanf


i would like to know if it is possible to use fread(which can read files fast) to load a file into a char buffer or similar then use fscanf or anything else to extract the formatted data? cheers
 
Old 12-20-2006, 09:20 AM   #2
demon_vox
Member
 
Registered: May 2006
Location: Argentina
Distribution: SuSE 10
Posts: 173

Rep: Reputation: 30
YOu mean tu read a file with fread and then parse the array with sscanf? (fscanf wil read from the file, so, dont read twice ). If thats the case, sure you can.... but I dont think that it will make any difference in performance. Besides, dont asume that your program will run slow when it reads from a file. Maybe your performance problems (if any) could be somewhere else.

Cheers!
 
Old 12-20-2006, 09:31 AM   #3
andystanfordjason
Member
 
Registered: Oct 2006
Location: england
Distribution: fedora 6
Posts: 38

Original Poster
Rep: Reputation: 15
the problem im having is that to run fscanf over the whole file is taking a long time, memory access and writing is almost no time and i know it almost takes no time to read the whole file into a buffer. so i was thinking i could read the file into a buffer then parse that, but i dont know how!
 
Old 12-20-2006, 09:36 AM   #4
andystanfordjason
Member
 
Registered: Oct 2006
Location: england
Distribution: fedora 6
Posts: 38

Original Poster
Rep: Reputation: 15
oh, actually i think thats exactly what i wanted, thanks a lot
 
Old 12-20-2006, 09:49 AM   #5
demon_vox
Member
 
Registered: May 2006
Location: Argentina
Distribution: SuSE 10
Posts: 173

Rep: Reputation: 30
Hehe I hit the solution by the tangent

Cheers!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C programming fread and fwrite using structures exvor Programming 4 09-26-2006 08:56 AM
fscanf returns -1 trutnev Programming 2 06-23-2005 08:50 AM
C fscanf / feof question. Claus Programming 1 02-02-2004 11:55 PM
fscanf c programming tomato Programming 14 01-09-2004 08:33 PM
using fscanf function Linh Programming 2 07-14-2003 12:58 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration