- struct lib
-
{
-
char *name,*author,*publish;
-
int price;
-
int no;
-
}u[50];
-
-
FILE *fp;
-
-
void fin() //Inputs data to a file
-
{ int i;
-
fp=fopen("abc.txt","w");
-
-
for(i=1;i<=n;i++)
-
{
-
-
fprintf(fp,"%s",&u[i].name);
-
-
putc('\t',fp);
-
fprintf(fp,"%s",&u[i].author);
-
-
putc('\t',fp);
-
fprintf(fp,"%s",&u[i].publish);
-
-
putc('\t',fp);
-
fprintf(fp,"%d",u[i].price);
-
putc('\t',fp);
-
fprintf(fp,"%d",u[i].no);
-
putc('\n',fp);
-
-
}
-
-
fclose(fp);
-
-
}
-
-
-
-
void fout() // Reads data from the file
-
{
-
int i,x,j=0;
-
char c,d[50];
-
d[0]='\0';
-
fp=fopen("abc.txt","r");
-
for(i=1;i<=n;i++)
-
{
-
fscanf(fp,"%s",u[i].name);
-
while((c=getc(fp))!='\t') ;
-
-
fscanf(fp,"%s",u[i].author);
-
while((c=getc(fp))!='\t') ;
-
-
fscanf(fp,"%s",u[i].publish);
-
while((c=getc(fp))!='\t') ;
-
-
fscanf(fp,"%d",&u[i].price);
-
while((c=getc(fp))!='\t') ;
-
-
fscanf(fp,"%d",&u[i].no);
-
while((c=getc(fp))!='\n') ;
-
-
}
-
fclose(fp);
-
-
}
The strings read from the file are not stored in the structure. If I try to display the strings they appear as <null> . The numbers are input without any problem.
Please help as soon as possible.
1 1337 horace1 1,510
Recognized Expert Top Contributor
the following are pointers -
char *name,*author,*publish;
-
but what do they point too?
should they be arrays? -
char name[20],author[20],publish[20];
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Tom Willis |
last post by:
How are the expert pythoneers dealing with config files?
Is there anything similair to .net's config files or java's .properties?
A quick search on google didn't return anything that looked useful,
and I almost would expect to see some module that would be for dealing
with config information.
I can think of at least one way to do it, but I'm sure there are
shortcomings I can't see yet, and I'd rather use something someone
|
by: ghause |
last post by:
I'm using a crypto stream to encrypt/decrypt files. It works fine with simple
files like .txt but butchers pdfs and xls. Is there a solid way to
encrypt/decrypt files that are more complex than plain text?
Thanks
|
by: serge |
last post by:
I am thinking about replacing the INSERT data script
files that I have with XML files. This way I can open the XML
file using an XML Editor and see the values in a GRID and
make changes easier.
Do you see any problem with this approach?
I managed to put together some code that is exporting
a SQL table with its data to an XML file and also a code
that reads the XML file's data and inserts it into a table.
|
by: Lev |
last post by:
Hi all,
Anybody know how to send email message with attached files via WebDAV for
Exchange (MS Exchange 2003 Server).
Please, please, please! Need help! ASAP!!!!
Tnx,
Lev
|
by: knapak |
last post by:
Hello
I'm a self instructed amateur attempting to read a huge file from disk... so
bear with me please... I just learned that reading a file in binary is
faster than text. So I wrote the following code that compiles OK. It runs and
shows the requested output. However, after execution, it pops one of those
windows to send error reports online to the porgram creator. I have managed
to find where the error is but can't see what's wrong....
| |
by: Peter Row |
last post by:
Hi,
Can someone give me a set of steps for an ASP.NET project (well actually its
just a
VB.NET class DLL that implements HttpHandler) that will work when moved
to another developers machine?
Here are some specifics:
1) The code, project/solution files are in MS Visual Source Safe
|
by: Roshawn Dawson |
last post by:
Hi,
Has anybody created an entire asp.net app using only ashx files? I know that they are simply
handlers used by the asp.net worker process. I hear that they are in some respects better than
using aspx files because they don't have to be compiled and don't need any page processing.
As an experiment, I'm creating an affiliate site that will use ashx files mainly. During testing I
haven't noticed anything different other than it seems...
|
by: inFocus |
last post by:
Hello,
I am new to python and wanted to write something for myself where
after inputing two words it would search entire drive and when finding
both names in files name would either copy or move thoe files to a
specified directory.
But couple of attempts did not work as desired this is one of them.
Could someone help fix it or maybe give a better example.
|
by: Alexnb |
last post by:
Okay, so what I want my program to do it open a file, a music file in
specific, and for this we will say it is an .mp3. Well, I am using the
system() command from the os class. The problem I am running into is that
when I send the path of the file to the system() command, which for those of
you who don't know the system command is the equivalent of typing one
command into command prompt or terminal depending on your system. But let's
say...
|
by: Alexnb |
last post by:
Gerhard Häring wrote:
No, it didn't work, but it gave me some interesting feedback when I ran it
in the shell. Heres what it told me:
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
os.startfile("C:\Documents and Settings\Alex\My Documents\My
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |