Hello all,
I'm a chemical engineering student. our teacher has given us a project to do some calculations based on some equations. those equations include constants, which are to be read from a file(I don't understand why?) i took an introductory course on c programming but the curriculum didn't include opening files, searching files and getting data from files. i made some searching through google and learned about opening and closing files, but i still don't know how to search for a string and how to get data from the same line as the string.
any help here would be appreciated. Thanks.
6 3304
I personally like this tutorial - it'll refresh you on the basics, as well as provide a reference for whatever File IO stuff you may need.
If you have any trouble coding it, feel free to post, though we do request that you take a gander at the Posting Guidelines.
Good luck!
I personally like this tutorial - it'll refresh you on the basics, as well as provide a reference for whatever File IO stuff you may need.
If you have any trouble coding it, feel free to post, though we do request that you take a gander at the Posting Guidelines.
Good luck!
I did look at the guidelines, and the program I'll write actually is a lot longer than the searching function. : )
thanks for the tutorial, but I don't know c++, I was inquiring about c. are there any sources for c tutorials like this one?
Ah, right, sorry about that - missed that part. Does this look like it will help?
Ah, right, sorry about that - missed that part. Does this look like it will help?
I looked at that one before, and there are actually questions in my mind about this one.
When I'm reading from a file, where do i put the file and what do i write for the filename part when using fopen(filename, mode)? for example, if my file is constants.txt, where should it be located for the program to see it and what should i write for the filename part?
in addition, this does not provide information about the behaviour of the functions fscanf and fprintf. for instance, in the while loop, it says to go on until end of file is reached. however, how does it pass to the next line in the file? does fscanf do it automatically?
i thought of that source to be inadequate. sorry to be bothering you so much but i looked at first 2 or 3 pages of google search when i type "c file open", "c fopen", "c search file" and "c file access" (searching each separately). any other help would be wonderful. : )
thanks, by the way : )
I looked at that one before, and there are actually questions in my mind about this one.
When I'm reading from a file, where do i put the file and what do i write for the filename part when using fopen(filename, mode)? for example, if my file is constants.txt, where should it be located for the program to see it and what should i write for the filename part?
in addition, this does not provide information about the behaviour of the functions fscanf and fprintf. for instance, in the while loop, it says to go on until end of file is reached. however, how does it pass to the next line in the file? does fscanf do it automatically?
i thought of that source to be inadequate. sorry to be bothering you so much but i looked at first 2 or 3 pages of google search when i type "c file open", "c fopen", "c search file" and "c file access" (searching each separately). any other help would be wonderful. : )
thanks, by the way : )
fopen takes two parameters
first is the file name(which u can specify the full path) and second is the mode
that is write or read etc.
When reading u can use fgets and every time you use fgets it automatically goes to the next line which is hanled by the System
Raghuram
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Roberto Dias |
last post by:
Hi,
I've got a text file and I need to capture some data in it. I
implemented ( using comp.lang.c++ help) a typical searching algorithm
that first find the header (label that identifies the data...
|
by: Julie |
last post by:
What is the *fastest* way in .NET to search large on-disk text files (100+ MB)
for a given string.
The files are unindexed and unsorted, and for the purposes of my immediate
requirements, can't...
|
by: Marco Castro |
last post by:
Im trying to create a system service that will read some records within an
access file. From these values I will then be able to see if other software
in the system is up to date and install the...
|
by: Geoff Jones |
last post by:
Hiya
I have a DataTable containing thousands of records. Each record has a
primary key field called "ID" and another field called "PRODUCT" I want to
retrieve the rows that satisy the following...
|
by: Learner |
last post by:
Hello,
Here is the code snippet I got strucked at.
I am unable to convert the below line of code to its equavalent vb.net
code. could some one please help me with this?
static public...
|
by: 2005 |
last post by:
Hi
I have a file that I am opening with
void main()
{
ifstream inFile("assign.data");
if (!inFile)
{
|
by: pbd22 |
last post by:
Hi.
I am somewhat new to this and would like some advice.
I want to search my xml file using "keyword" search and
return results based on "proximity matching" - in other words,
since the search...
|
by: warheart |
last post by:
hi
im kinda new to programming
i aint lazy to search and learn :D
but i am getting despirate...
ive been looking everywhere for a code to search a txt file and find a string,
and then give...
|
by: DennisBetten |
last post by:
First of all, I need to give some credit to Mahesh Chand for providing me with an excellent basis to export data to excel.
What does this code do:
As the title says, this code is capable of...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| | |