The problem starts during my while loop. It checks to see if they hit x
or X. If they did, then that means the user wants to exit. Then should
go on and hit the return statement. It just quits. When I hit x, it
pauses for a second then just goes to the next line on the cmd prompt.
My other returns work just fine though. I'm sure its just a stupid
logical error somewhere that I havn't caught. If anyone can point out
any tips that or whats wrong with it that would be great. Thanks again
to all!
int editBook(int a)
{
///////used to hold new values///
char xisbn[14];
char xtitle[51];
char xauthor[51];
char xpublisher[31];
char xdate[11];
int xqty;
float xwholeSale;
float xretail;
/////////////////////////////////
char change ='z';
char lookUp[51];
bool found = false;
system("cls");
cout << "\n\t\tEnte r the title of the book you wish to edit ";
cin >> lookUp;
system("cls");
for(int index = 0; index < 20 && !found; index++)
{
// toupper
char up1[51], up2[51];
for(int position=0; position < 51; position++)
{
up1[position] = toupper(lookUp[position]);
up2[position] = toupper(bookTit le[index][position]);
}
if (strcmp(up1, up2) == 0)
{
found = true;
bookinfo(isbn[index], bookTitle[index], author[index],
publisher[index], dateAdded[index], qtyOnHand[index], wholesale[index],
retail[index]);
}
}
if(!found)
{
cout << "Book not in Inventory";
return 0;
}
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
while (change != 'x' || change!='X')
{
if (change == 'I' || change =='i')
{ cin.ignore();
cout << "Enter the new ISBN number: ";
cin.getline(xis bn,14);
strcpy(isbn[index], xisbn);
cout << "The isbn is now " << isbn[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'T' || change =='t')
{
cin.ignore();
cout << "Enter the new Title: ";
cin.getline(xti tle,51);
strcpy(bookTitl e[index], xtitle);
cout << "The title is now " << bookTitle[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'A' || change =='a')
{
cin.ignore();
cout << "Enter the new Author: ";
cin.getline(xau thor,51);
strcpy(author[index], xauthor);
cout << "The author is now " << author[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'P' || change =='p')
{
cin.ignore();
cout << "Enter the new Publisher: ";
cin.getline(xpu blisher,31);
strcpy(publishe r[index], xpublisher);
cout << "The publisher is now " << publisher[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'D' || change =='d')
{
cin.ignore();
cout << "Enter the new Date: ";
cin.getline(xda te,11);
strcpy(dateAdde d[index], xdate);
cout << "The date is now " << dateAdded[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'Q' || change =='q')
{
cout << "Enter the new Quantity on Hand: ";
cin >> xqty;
qtyOnHand[index] = xqty;
cout << "The Quantity on Hand is now " << qtyOnHand[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'W' || change =='w')
{
cout << "Enter the new Whole Sale: ";
cin >> xwholeSale;
wholesale[index] = xwholeSale;
cout << "The Whole Sale is now " << wholesale[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
if (change == 'R' || change =='r')
{
cout << "Enter the new Retail: ";
cin >> xretail;
retail[index] = xretail;
cout << "The retail is now " << retail[index];
cout <<"\n\nEnter the first letter of the category you would like to
edit or 'x' to exit: ";
cin >> change;
}
}
return 0;
} 4 1635
"GRoll21" <mr*****@gmail. com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com... The problem starts during my while loop. It checks to see if they hit x or X. If they did, then that means the user wants to exit. Then should go on and hit the return statement. It just quits. When I hit x, it pauses for a second then just goes to the next line on the cmd prompt. My other returns work just fine though. I'm sure its just a stupid logical error somewhere that I havn't caught. If anyone can point out any tips that or whats wrong with it that would be great. Thanks again to all!
while (change != 'x' || change!='X')
while (change != 'x' && change != 'X')
-Mike
aww man. i really need to take a lil break. something so stuipd i
should of caught. thanks very much though for pointing it out!
- mike
"GRoll21" <mr*****@gmail. com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com... aww man. i really need to take a lil break. something so stuipd i should of caught. thanks very much though for pointing it out!
It's been my experience that such 'dumb' mistakes
are often the result of trying to write too much
code at once.
Write your code in small increments, and TEST, TEST, TEST!!
(I was able to quickly diagnose the trouble by deleting
99% of that code you posted, replacing it with:
#include <iostream>
using namespace std;
int main()
{
char change(0);
bool condition(false );
cout << "Enter: ";
cin >> change;
while (condition = (change != 'x' || change!='X'))
{
cout << "inside loop, condition == " << condition << '\n';
}
cout << "loop done, condition == " << condition << '\n';
return 0;
}
The problem became immediately obvious.
-Mike
"GRoll21" <mr*****@gmail. com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com... The problem starts during my while loop. It checks to see if they hit x or X. If they did, then that means the user wants to exit. Then should go on and hit the return statement. It just quits. When I hit x, it pauses for a second then just goes to the next line on the cmd prompt. My other returns work just fine though. I'm sure its just a stupid logical error somewhere that I havn't caught. If anyone can point out any tips that or whats wrong with it that would be great. Thanks again to all!
int editBook(int a) {
///////used to hold new values/// char xisbn[14]; char xtitle[51]; char xauthor[51]; char xpublisher[31]; char xdate[11]; int xqty; float xwholeSale; float xretail; /////////////////////////////////
char change ='z'; char lookUp[51]; bool found = false;
system("cls"); cout << "\n\t\tEnte r the title of the book you wish to edit "; cin >> lookUp; system("cls");
for(int index = 0; index < 20 && !found; index++) { // toupper char up1[51], up2[51]; for(int position=0; position < 51; position++) { up1[position] = toupper(lookUp[position]); up2[position] = toupper(bookTit le[index][position]); } if (strcmp(up1, up2) == 0) { found = true; bookinfo(isbn[index], bookTitle[index], author[index], publisher[index], dateAdded[index], qtyOnHand[index], wholesale[index], retail[index]); } }
if(!found) { cout << "Book not in Inventory"; return 0; }
cout <<"\n\nEnter the first letter of the category you would like to edit or 'x' to exit: "; cin >> change;
while (change != 'x' || change!='X')
This will always be true. You want to AND them, not OR them.
while (change != 'x' && change != 'X' )
same with the rest. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: muser |
last post by:
Can anyone run this program through their compiler or if they can see
a logical error please point it out. I have my tutor working on it at
the moment but I would rather a less ambigious response than the one I
think he will provide.
The test data, A:\\"514650.txt", appears at the end of the program.
The problem is that the program won't read this file and the debugger
as far as i know how to work it won't point out the mistake of any....
|
by: Hari Om |
last post by:
Here are the details of my error log files:
I execute the command and get following message at console:
----------------------------------------------------------------------
../sqlldr scott/tiger@common control=/full_path/test.ctl
log=/full_path/adhoc/test.log
SQL*Loader: Release 9.2.0.1.0 - Production on Tue Sep 2 10:49:27 2003
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
|
by: Christopher Benson-Manica |
last post by:
Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I'm working on). Am I the only one who
would find it useful?
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
|
by: moosdau |
last post by:
it's likely that the compiler could only promise returning a non-zero
value in my impression,
but it did return 1 every time,
like the code below:
int a=3,b=8;
printf("%d\n",a<b);
will it return 1 absolutely in any case?
|
by: ThunderMusic |
last post by:
Hi,
I have a value that contains flags that I must get using a bitmask. I tryied
with the && operator, but the compiler outputs this error :
Operator '&&' cannot be applied to operands of type 'int' and 'int'
The code is the following :
// MASKS.Insert = 2
if (_RightMask && (int)MASKS.Insert)
| |
by: Roald |
last post by:
I am working on an application that needs to implement logical deletes
instead of removing the records permanently. The logical delete works
by setting 3 fields (deleted flag, date and user). I have been trying
to replace the DeleteCommand query text of the FormView with an UPDATE
statement, but keep getting an error 'Must declare scalar variable
@delete_user'.
The update statement looks like this:
UPDATE SET = N''Y'', =
|
by: blueboy |
last post by:
Hi,
I am planning to automate a nighty restore of a DB on another server
can someone point me in the right direction with the SQL script to
modify the logical file names to the correct path and not the ones
carried over with the DB??
i.e the database is to be renamed on the new server
any help much appreciated
|
by: Dominic Vella |
last post by:
I am using MS-Access2000. I can't seem to set the default values for Logical
type fields. I start with
Dim dbsTmp As Object ' I think it's DAO.Database
Set dbsTmp = DBEngine.OpenDatabase(CurrentProject.path & "\data_be.mdb")
and then use the following to run my SQL ststement
dbsTmp.Execute
-----------------------------------------------------
Something like this SQL statement works:
"ALTER TABLE tblStudent ADD COLUMN student_number...
|
by: raylopez99 |
last post by:
I have a logical drawing space much bigger than the viewport (the
screen) and I'd like to center the viewport (the screen) to be at the
center of the logical drawing space. After following the excellent
transforms specified on Bob Powell's site, I still wonder if there's
an easier way of centering it than the following procedure?
Here is what I do now (it's awkward but it works):
1) I follow the transforms specified on Bob Powell's...
|
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: 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
| |