0

How to make string stay on the same line

input: 3 output: &&& | | | what i get: & | & | & | I think that there should be some kind of operator for this but i im a total noob so i dont know it. thanks in advance

28th Oct 2016, 1:26 PM
Linards Liepenieks
Linards Liepenieks - avatar
3 Respostas
+ 1
It would be great, if you can provide your code :) But it looks like you are outputting '&', then '|' 3 times and after each one is new line. That can be caused by character '\n', or endl in cout << endl. I don't know if I got your question right. This should output &&& ||| if you input 3: int n; cin >> n; for(int i = 0; i < n; i++) cout << '&'; cout << endl; while(n--) cout << '|'; cout << endl;
28th Oct 2016, 2:11 PM
Daniel Oravec
Daniel Oravec - avatar
0
hii if i m not wrong ur coding will become an infinite loop as n>0 is not specified but i like coding
28th Oct 2016, 3:02 PM
Pravendra Khichi
Pravendra Khichi - avatar
0
Yes, you're right :) But that is just illustration, program will crash also if you input string instead of integer, but I hope everybody gets the idea :)
28th Oct 2016, 3:08 PM
Daniel Oravec
Daniel Oravec - avatar