I have Problem of some part of my program , my program is working but theres something wrong.
Kindly check please .. The Password is guest , this is my project and i need to pass it on friday ...
include <cstdlib>
include <iostream>
include <string>
include <sstream>
using namespace std;
int main(int argc, char *argv[])
{
string terminate;
char code;
char access;
int r;
int link[]={'1','2','3','4','5','6','7','8','9','10'};
string item[10]={"T-Shirt\t","Long Pants","Wallet\t","Cap\t","Underwear","Belt\t","Bags\t","Handkerchief","Perfumes","Short Pants"};
float sum = 0,vat = 0,vat1 = 0,mon = 0,total = 0;
int arrays[10]={450,800,185,150,150,130,400,50,180,500};
I did compile your code in VC++. It generates the following warnings:
main.cpp(93) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
main.cpp(13) : warning C4101: 'r' : unreferenced local variable
The first requires line 93 to be:
vat = sum * .12f;
The second, either r is redundant, or you forgot to use it and teh code is incomplete perhaps.
I even ran the code, I still have no idea what "correct" operation should be. However, beware that console stream input functions are line buffered, so when you use formatted input and expect a number, the get does not return until a whole line is entered, but only the numeric characters are processed, leaving the <newline> character buffered, so the next input sees a blank line which your code reports as "invlaid input".
After input that does not get the whole line, you need to flush the line with:
You display a list of integers, 49 for example is the decimal ASCII character code for '1', which is what is output. I doubt that that is whet you intended.
I doubt that those are the only flaws, but it should get you moving.
What classes should teach at this stage is debugging techniques, but few seem to bother.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Don't make us work that hard. What is the code intended to do, what does it do that is not correct. Fore example describe the expected and actual behaviour.
Also, it seems that you have till Friday, that would be plenty of time to debug this yourself.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have Problem of some part of my program , my program is working but theres something wrong.
Kindly check please .. The Password is guest , this is my project and i need to pass it on friday ...
include <cstdlib>
include <iostream>
include <string>
include <sstream>
using namespace std;
int main(int argc, char *argv[])
{
string terminate;
char code;
char access;
int r;
int link[]={'1','2','3','4','5','6','7','8','9','10'};
string item[10]={"T-Shirt\t","Long Pants","Wallet\t","Cap\t","Underwear","Belt\t","Bags\t","Handkerchief","Perfumes","Short Pants"};
float sum = 0,vat = 0,vat1 = 0,mon = 0,total = 0;
int arrays[10]={450,800,185,150,150,130,400,50,180,500};
}
I did compile your code in VC++. It generates the following warnings:
main.cpp(93) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
main.cpp(13) : warning C4101: 'r' : unreferenced local variable
The first requires line 93 to be:
The second, either r is redundant, or you forgot to use it and teh code is incomplete perhaps.
I even ran the code, I still have no idea what "correct" operation should be. However, beware that console stream input functions are line buffered, so when you use formatted input and expect a number, the get does not return until a whole line is entered, but only the numeric characters are processed, leaving the <newline> character buffered, so the next input sees a blank line which your code reports as "invlaid input".
After input that does not get the whole line, you need to flush the line with:
std::cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
(which required that <limits> is included.
ref: http://www.augustcouncil.com/~tgibson/tutorial/iotips.html#directly
Another observation is that you have declared:
int link[]={'1','2','3','4','5','6','7','8','9','10'};
which is an integer array initialised with character constants. Here:
for(int y=0;y<=9;y++)
{
cout<<"\t\t"<<link[y]<<endl;
}
You display a list of integers, 49 for example is the decimal ASCII character code for '1', which is what is output. I doubt that that is whet you intended.
I doubt that those are the only flaws, but it should get you moving.
What classes should teach at this stage is debugging techniques, but few seem to bother.
Clifford
Don't make us work that hard. What is the code intended to do, what does it do that is not correct. Fore example describe the expected and actual behaviour.
Also, it seems that you have till Friday, that would be plenty of time to debug this yourself.
Clifford