jjh 21
New Member
So with infile I have this so far:
#define MAXBOOKS 9
ifstream infile("library .txt");
struct Book
{
title[MAXBOOKS]
}
while(true)
{
for(int i = 0; i < MAXBOOKS; i++)
{
char tempTitle[MAXBOOKS];
infile.getline( book.title, MAXLENGTH);
}
}
I also have the main function, but my question is with the getline. My problem is how do i get the book.title to go into the title[0].
if i try to declare it by setting book.title[0] = book.title, I come up with an error obviously.. but how do i get the infile into book.title[0]????
Sep 24 '06
15 4865 jjh 21
New Member
I tried this : -
for(int i = 0; i < MAXBOOKS; i++)
-
{
-
-
string tempTitle;
-
infile.getline(theBook[i].title ,MAXLENGTH);
-
cout << theBook[i].title;
-
}
-
and then i got the error
c:\documents and settings\owner\ my documents\visua l studio 2005\projects\h w 4\hw 4.cpp(33) : error C2664: 'std::basic_ist ream<_Elem,_Tra its> &std::basic_ist ream<_Elem,_Tra its>::getline(_ Elem *,std::streamsi ze)' : cannot convert parameter 1 from 'char' to 'char *'
with
[
_Elem=char,
_Traits=std::ch ar_traits<char>
]
The message i am trying to bring it is "Principles of chem"
Banfa 9,065
Recognized Expert Moderator Expert
Not if you are using the structure -
struct Book
-
{
-
char title[MAXTITLE];
-
char keyWord[MAXKEYWORDS][MAXLENGTH];
-
char position;
-
};
-
-
struct Book theBook[MAXBOOKS];
-
you aren't so I suspect you aren't doing that or you haven't change the code correctly.
jjh 21
New Member
Ok i got that alright and thank you, but one other thing...
The file I am wanting to bring in, is read like this...
Title
keyword
keyword
$
my problem now is how do I make the key words is a single array... Is there a way to call theBook[i].keyword[j] and have j as a inside for loop???
jjh 21
New Member
Oh I am sorry i didn't even see it. Thank you so much.
Can I ask a question on this thread?
What if you have no idea how big the infile is? How do you set MAXBOOKS and MAXLENGTH?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bruce A. Julseth |
last post by:
When I execute this SQL statement in my PHP code, I get an error
"File '.\Address.txt' not found (Errcode: 2)"
$File = addslashes(".\Address.txt");
$SQL = "Load Data InFile \"" . $File . "\" into table addresses";
$result = mysql_query($SQL) or die(mysql_error());
The file is located in the same directory as my .PHP file.
How do I generate a relative address for this file so that it can be found?
|
by: las |
last post by:
I'm having a wee problem with the get method, here is my code :
ifstream infile;
char x;
infile.open("temp.txt");
if( !infile.good() )
{
cout << "Error opening file" << endl;
system("PAUSE");
exit(1);
}
|
by: Donald Tyler |
last post by:
Then the only way you can do it that I can think of is to write a PHP script
to do basically what PHPMyAdmin is trying to do but without the LOCAL in
there.
However to do that you would need to be able to place the PHP file on the
server, and I guess you probably can't do that either. Talk about catch
22...
The only other way I can think of is to install MySQL on a machine you
control, then import the data there using the method I...
|
by: Steffen |
last post by:
Hello,
I´m using mysql 3.23.58 and I want to enable the local-infile option.
The manual on dev.mysql.com says the following to that:
.....
If you use LOAD DATA LOCAL in Perl scripts or other programs that read
the group from option files, you can add the local-infile=1
option to that group. However, to keep this from causing problems for
programs that do not understand local-infile, specify it using the
|
by: Ray in HK |
last post by:
What are the differences between LOAD DATA INFILE and LOAD DATA LOCAL INFILE
?
I found some web hosting company do not allow using LOAD DATA INFILE but
allow LOAD DATA LOCAL INFILE. The reason is for the sake of security. What
does that mean ?
| |
by: Jason3231 |
last post by:
well i've found and pieced together a script (mainly found; i'm very new to perl) to scan a group of cisco switches that i have and print information out in a text file. everything seems to work pretty well except when a particular cmd doesn't apply to one of the switches listed in my infile. the script seems to get stuck in these instances and closes without going to the next valid switch. maybe i need some sort of ELSE type of statement or...
|
by: joelagnel |
last post by:
hi friends,
i've been having this confusion for about a year, i want to know the
exact difference between text and binary files.
using the fwrite function in c, i wrote 2 bytes of integers in binary
mode.
according to me, notepad opens files and each byte of the file
read, it converts that byte from ascii to its correct character and
displays
|
by: jjh |
last post by:
Trying to input a file
say file.txt
The first line I am trying to input is: Principles of Biochemistry
Trying to put "Principles of Biochemistry" into a char array book.title
with a max of MAXBOOKS
Why wont it work when I use...
infile.getline(book.title, MAXBOOKS);
|
by: waltbrad |
last post by:
Hello. I'm studying the book "C++ Primer Plus" by Stephan Prata. In
chapter 6 he gives an exercise that reads from a file. The list is
thus:
4
Sam Stone
2000
Freida Flass
100500
Tammy Tubbs
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: 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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |