how do i shift the place where the user types something

Pages: 12
I made a program that calculates a determinant(3X3).
Now, what i want is to make the program user-frendly, so i want to shift the place where the user can type in the numbers.
So, such a determinant looks like this:
a11 a12 a13
a21 a22 a23
a31 a32 a33

Ok, i want that when the user types in the numbers that is does not look like this on the console:
1
2
3
4
5
6
7
8
9

but it needs to look like this:
1 2 3
4 5 6
7 8 9
When using cin, the user could type it in either way.

Here's something that may help.
http://www.cplusplus.com/forum/beginner/16541/#msg82769

Inside the loop, but after creating the stringstream, just add another loop to read three values to populate your matrix.

Hope this helps.
press TAB between two numbers in a row and press ENTER after every three inputs (three numbers to goto next line)


enter ele

1        2      3

4       5       6

7       8       9
hmm... none of that helped me out, well, im not too advanced, i didnt even finished my first semester yet, so i guess im still not able to understand ur solutions
in the out put screen : for u r 3Xx3 Martix give inputs as i mentioned below.


1 'perss TAB ' give input as 2 'press TAB' give next input 3 'press ENTER'

4 'perss TAB ' give input as 5 'press TAB' give next input 6 'press ENTER'

7 'perss TAB ' give input as 8 'press TAB' give next input 9 'press ENTER'
so basicly what ur telling me is that i say to the user that he types in the first number, then press tab, the secounnd number press tab...?
hi ..
you can't do it using the regular (cin) . it waits till the user ends the input by himself and the user chooses the way he ends it , either by pressing enter or spaces :

------------------------------------------------------------------------------------------------------------
1
2
3
4
5
1
2
3
4
5

Here the user ends input using enter, the inputs are read one by one

1 2 3 4 5
Here the user enters the values separated by spaces, the inputs are still read after pressing enter, they are read all together.
------------------------------------------------------------------------------------------------------------

conclusion : you can't do what you are thinking of using regular cin.
however there is a clumsy way that i thought of in my early days.
you can ask the user to enter each number, then before entering the next, you clear the screen, then output the previous elements in the desired order, then wait for entry for the next number.
for more details on how to clear the screen : use
system("cls");
First off, this topic is a month old.

Second off, don't tell the OP that you cannot do it with cin, especially after I (or someone else) has already posted how to do just that.

Thirdly, the user didn't ask how to clear the screen for each input. He asked how to get three inputs per line, so that the input looks like a matrix.

Finally,
  Don't use system(): http://www.cplusplus.com/forum/articles/11153/
  If you must clear the screen: http://www.cplusplus.com/forum/articles/10515/
@ Duoas

1. yes, this is month ago, but the last reply before me was hours ago, so this topic is active, and the user didn't flag it as solved.

2. the user stated clearly that he didn't understand you bec. he isn't advanced enough.

3. i told him it is a clumsy way to user if he didn't find another way. solve it then criticize other s people work.

4. this is a HELP thread, not offence one, i've got much help from this site and want to give back some, so, correct a wrong statement ( if it existed ) but don't attack the user.

Best Wishes ...
the last reply before me was hours ago
Only if you're living in November.
M364M4Ncro (3) Nov 27, 2009 at 11:34am
oamsath (8) Dec 27, 2009 at 03:13am
@ oamsath

Hey, that actually is a pretty good idea to use for someone who is still learning how to use functions thx.

Well, i think i can call this topic solved.
@oamsath

What!?

Just for the record, I did not, at any time, attack you. So don't get huffy and puffy.

solve it then criticize other s people work.
You're kidding, right? I did solve it. Pretty easy too... sorry it was above the OP's head, but hey, ramesh's answers seemed to work, right? (Seeing as the OP didn't ask for more.) No one can be asked to assume more than that until the OP asks for clarification.

correct a wrong statement ( if it existed ) but don't attack the user.
Fine. Consider yourself corrected. And not attacked.

Don't take offense where none is intended.

Also, I happen to know a lot about UI design. Clearing the screen for every input is a Bad Idea. And using system() to do it is sufficiently worse that if I were your professor, I'd drop you a grade point for the project for doing it against the better instruction given to you.

It is not an attack to say, "Don't do that." It is a kindness engendered by the brotherly nature that experienced hackers share.

But when you bite back for percieved offenses, you'll quickly find that quality help disappears.
It's so annoying that there is no way to make new users more aware of some of these extrmely useful articles... *sigh*...
@Duoas

dude, u know, the first what u told oamsath is that this topic is a month old. Somehow that did sound like an attack.
But dont get me wrong, i appritiate that u are trying to help me, but right now, im in my first semester, so some of ur solutions are hard to understand for me.
Second. Oamsath's solution helped me, but i can actually upgrade his solution using loops and arrays (i learned arrays rather recently).
And i will use system("pause"), cuz i dont know any other way, and as i said, ur solutions are not understandeble for me.
And my mother language is NOT english, and in programming english got some words i dont 100% understand, i mean i understand them, but i just gen a question marker, if u understand what i mean.
So sooner or later, in my fakulty they will surely explain better ways how to clear screen on MY language and then i will surely understand it.
But dont get me wrong, i appritiate that u are trying to help me, but right now, im in my first semester, so some of ur solutions are hard to understand for me.

I understand that it can be hard learning things you haven't come across before but it's important that you go away, research anything new you have been given and try to use them. This is a forum where people are reguarly programming where some even do it as a profession, so when they tell you to do it a certain way, it is usually for a reason.

And i will use system("pause"), cuz i dont know any other way, and as i said, ur solutions are not understandeble for me.

As I heard chrisname say the other day, prevention is better than curing. Why get into bad habbits now just so you can go through the hassle of ridding yourself of them later on? Please take the time to look through the articles Duoas has kindly got for you.
@mcleano

there is a reason why they teach them to use system() at first.
Its because it is a simple metode.
Think about it: How will u explain a TOTAL BEGINER who never heard about programing those rather complicated procedures of doing stuff whitout system(). U cant!!!
If u want to teach programing, then u got to go from point zero.
I mean, common!! I got to one dimesional static arrays, and i got no idea how to use the solutions Duoas gave, how do u expect someone who never heard about programming to understand it.
I learn programming in my faculty, and we always use system(), but im pretty sure when we go further away, they will tell us that system() is bad and why, and they will tell us better ways.

For instance, from the begining, they told us to write the main function like this:
void main(){block of orders}

but when we got to functions, then they told us that its better to write:
int main(){
block of orders
return 0;}
there is a reason why they teach them to use system() at first.
Its because it is a simple metode.

Just becase something is simple doesn't mean it is the best way to do it. In this case, it definately isn't.

For instance, from the begining, they told us to write the main function like this:
void main(){block of orders}

but when we got to functions, then they told us that its better to write:
int main(){
block of orders
return 0;}

Then I am glad my knowledge of C++ has been self-taught, barring the vital knowledge I have learnt from the members of this forum, especially Duoas and Helios who have both gave input in this thread (although Helios not exactly helpful to the problem lol)

Of course, everything you choose to do when coding and learning is your own decision, I am just trying to help you. I understand your points on using methods that are easier to begin with and in some instances I would do the same, but that is not the case with system().
a TOTAL BEGINER who never heard about programing
He shouldn't be learning C++, IMO.

If u want to teach programing, then u got to go from point zero.
Which isn't C++.

from the begining, they told us to write the main function like this:
void main(){block of orders}
You were taught wrong.

For starters, any teacher that teaches how to leave a console open after a program finishes is already failing to teach C++.

It's much easier to teach how to do it right from the beginning, even if it means just glazing over it to explain in further detail later on, than to teach less-than-ideal methods first to then have them un-learn them in order to teach better ones. Humans are creatures of habit.
Ok, M364M4Ncro, now you are becoming a bit rude and overspoken.

You obviously know nothing about pedagogy. As a beginner in programming, you also don't know enough to properly argue what is simple and what is not. Your comments indicate that you don't really understand what system() does anyway.

This is your topic, so you are certainly allowed to take from it what you want. Heck, you can even post whatever drivel you want people to believe -- considering your obvious understanding of what the right answer ought to be.


It does seem odd, however, to instruct the instructor. And I don't think other people reading here ought to get "well it must be okay, at least sometimes" from reading a discussion I've participated in.

No matter what you are learning, there is always a "learning curve" that translates to the simple fact that you will not understand everything at first blush.


Oh, and by the way, the "reason why they teach them to use system() at first" is not what you think. The sad truth is that your instructor or instructors either
  1. don't know any better, or
  2. are being lazy
There is little excuse to ruin a new programmer's mind by teaching bad mojo. If you were to apply the same reasoning to other disciplines, you'd get similar rubbish:

  Don't worry about the gas and break pedals yet. Just steer and use the shifter.

  Don't worry about food safey yet. For now just dunk everything in formaldehide.

  Don't worry about the ground wire yet -- we'll get to that when we study electrical safety.
  In the meantime, just clip it to the box. (Sure, it might kill someone someday, but it is very
  simple and easy.)

Think that's an over-the-top reaction? It isn't. If you are serious about software, don't subvert security by using system() blithely.


One final note about learning. You'll get a much better response if you simply say things like,
Hey, I read through your post but I don't think I understand what you mean by "use a stringstream". We haven't covered streams yet in class
and
Gosh, I realize that the user can format the input any way he wants. But I'd like to force him to input it like it was a matrix. Is there a simple and easy way to do that for a beginner like me?
instead of
Well, I'm going to breath fire at you people because you both disagreed with the poster who gave me an answer I liked.

As I've already said, when you bite back for percieved offenses, you'll quickly find that quality help disappears. And so, now my help will disappear.

Not that you care, apparently.
@Duoas

if any part of my post was offensive, then im sorry.

second: you are right in your final note, i should have articuled myself better

third: about teaching other ppl, there are obviously multiple ways to do that, and its hard to say which ones are best. I have been thought pretty much like i explained, and i must say it was pretty good.
If i was criticizing ur way of teaching, then i was wrong, cuz im pretty sure that u helped much ppl that way, and if i would be thaught by ur model, then i would get pretty far too.

And by the way, while surfing through this site, i found many post's stating that those system() are bad.
Dude, i belive it, really, if u ( a obviously advanced programmer) say that they are bad, then i belive u.
If i see system(), then i know it is bad.When i go make a program for comercial purpose, then belive me, i will avoid system() whenever i can.
But while im doing some petty programs for fun, or some homework, then it really isnt so important.

Well, I'm going to breath fire at you people because you both disagreed with the poster who gave me an answer I liked.


I did not intend that my post looks like that.

Not that you care, apparently.

That is apsolutly and 100% NOT true.
I apretitate every help and attemp of help, belive it or not.

And on final note:
I send an help request with this topic, and i got an solution, and i marked this topic as solved, so i think if we are to go on with the topic of this conversation, then we should do it on another topic
Pages: 12