Yeah, you just need more then the default level of control that a simple C++ app gives you over the consule. What platform are you writing on? What libs are you familar with?
Dont exactly get ur question...but from what i get it...do it in a while loop. I have no idea what is your control factor but ill give you an example. Not sure if this is what u mean but have a look...
1 2 3 4 5 6 7 8 9 10
int condition;
do
{
... //all your couts and cin
//finally
cout<<"enter 0 to exit"<<endl;
cin>>condition;
}while(condition);
I have skipped error checking, please do it(check if condition is an integer)
This will do what you need in a loop...There are many ways you can do it though
I'm just starting (couple of college classes, but I still feel like I'm just starting) in C++ programming, so I'm not familiar with many libraries. Right now I'm switching between Visual Studio 2010 (Windows 7) for college work and Code::Blocks (Ubuntu) for messing around.
I was just curious on how it is achiveable in C++, for like self-learning, practice.
I think the OP wants the display to always have those items listed, then have the cursor start at "Part Name:" then move down to "Description:" and so on. In which case all of the 3rd party libs I regularly work with (Win32, SFML and SDL) allow you to reposition the cursor. You just have to use a different approach then "std::cout".
Yeah, but like that will print the other "couts "AFTER the user inputs the "part name", etc. I ment it so it prints all the "couts" and then wait for user input so that it prints the data.
Part Name:
Description:
Availability:
Price: $
after user enters part name:
Part Name: Example
Description: Example's description
Availability: 20
Price: $ 30.00
@ OP: You'll need to be familiar with at least one of these libraries. I recommend SFML, you can pick up on how to do this in about an afternoon and come here if you have any questions.
I know what you mean. Okay in that case you will have to have a class of these parts stored somewhere in a list structure or other data structure. U can use STL library. Once the user enters a partname, you search through the list to find the matching partname and then get the other info and print them...
I did a search on modifying cursor position and I found:
1 2 3 4 5 6 7 8 9 10 11
#include <windows.h>
#include <iostream>
usingnamespace std;
void gotoxy( short x, short y ) {
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
COORD position = { x, y };
SetConsoleCursorPosition( hStdout, position );
}
Using that I did a little driver to try it out and it worked like I wanted. I know it has some system("cls"), but it was just a quick code so I could show you guys what I meant.
Well, it does what I wanted but I want to understand it :P ... I'll take a look at SFML once I get it to install on VS2010, I wanna keep learning these type of things, Thanks :D
k now i get what you exactly wanna do....but this is a bad programming style..cos it does not give way to expansion and deletion. Say the programer accidentally deletes partNumber[i] without also deleting the rest at that ith location. And then he inserts a different partNumber[i] at that ith location, then the info you produce will be not correct one.
My suggestion is to use stl, where when u delete a partNumber[i], all the members associated with it also gets deleted.
There are more conceptual errors with your code here though it will work just fine but not good for dynamically emerging code.