ive really been stuck
http://img91.imageshack.us/img91/7803/letterssu2.gif
and i dont know where to begin
Printable View
ive really been stuck
http://img91.imageshack.us/img91/7803/letterssu2.gif
and i dont know where to begin
I have absolutely no idea what you're asking...
how do i make the text go like that in c++
cout<<"a b a\n";
If you mean to be able to change stuff on the screen without it scrolling and junk, checkout curses, thats some fun stuff.
Seriously man, you couldn't possibly be less descriptive. It's literally impossible. I asked God. He agrees... it's impossible in this universe.
I'm sure you can spend 30 seconds of your life writing something meaningful for us to work with.
I think he may want to, hmm, change those chars mechanically, like this:
Code:#include <iostream>
using namespace std;
int main()
{
char letter=66;
for(;;)
{
letter--;
cout<<letter;
letter++;
cout<<letter;
letter--;
cout<<letter;
letter++;
cout<<endl;
}
cin.get();
}
That code will never run
Code:#include <iostream>
#include <string>
using namespace std;
// This is a horozontal version of what I think
// (note we cannot help much if you're always
// this illucid), you want. edit for vertical.
int main ( void )
{
string A = "AAAAAAAAA\n",
B = "BBBBBBBBB\n";
char ID = 'A';
while ( true )
{
cin.get();
if ( ID == 'A' ) cout<< A;
else cout<< B;
ID == 'A' ? ID = 'B': ID = 'A';
}
return 0;
}
Why? Do you see mistakes? It runs on my Dev-Cpp 4.9.9.2 as I expected.Quote:
Originally Posted by Mario F.
If I see mistakes?
Did you actually ran your code, or are you being smart?
The code compiles and runs, I know I'm not smart, so please correct me. Are you about that infinite for(;;) loop? Try to compile and run it, I really want to know what's wrong there, because I won't find out myself. Also, it's not actually all code, i'd never use that loop in my programs without break; in it.
You were asked repeteadly to be more precise in what is that you want to do. You ignored these requests. Do you expect me to be more precise by explaining to you what do I mean by will not run?
I don't need to compile and run it to know it will not do what is expected. You entered an infinit loop. Your processor will jump to 100% usage and the only way to stop it is to abort the program execution. cin.get() will never run.
If you compiled and executed your own program you certainly saw this. So why ask me what is wrong. It's right there under your nose.
And... lilhahawk, do us all a big favor and do please explain once and for all what is that you want to do.
Yup, there's nothing wrong with the code. It's just a meaningless program programmed in a bit silly way. I believe this would be an easier way to print "ABA" endlessly :)
Edit: Mario, you are not replaying to the OP. Since he doesn't elaborate onhis wishes we're just proposing meaningless solutions.Code:while (1)
std::cout << "ABA\n";
You should probably take a look at the name of the OP and the name of who you've been replying to this whole time. Also, saying something won't run when it does and meaning it won't run properly are two different things.Quote:
Originally Posted by Mario F.
I didn't even realize I said so until now. Should have added "as expected".Quote:
Originally Posted by SlyMaelstrom
EDIT: I confused you with Lilhawk overload. For that I'm sorry. Still... your code is no good. Do please read the tutorials on this website about for loops. They are only very rarely used as you did.
Actually, my code wasn't intended to be used, I just wanted to give lilhawk a little clue (though I don't know what does exactly he want)... I'd never use that loop without a break; statement in it, otherwise it's useless.
>> They are only very rarely used as you did.
Infinite loops are used all the time. The code was fine as an example.
No. It was not. As the cin.get() at the end so very well shown it was a bad example. It was flawed. It was an infinit loop and it was badly implemented. Nice to see you find this type of code "fine as an example", Daved. Will keep that in mind.
I left cin.get() there from another program with no loops at all, just forgot to take it out, forgive me my laxity :p
>> Nice to see you find this type of code "fine as an example", Daved. Will keep that in mind.
That is so dumb. Are you even reading this thread? It reminds me of someone closing their eyes and replying to random bits of conversation as they're being pushed around.
I can't even see why an unconditional [while(1), for(;;)] loop is poor style if you have a condition inside of it, uh, making it conditional?
Mario, please stop. I find your attitude to be obnoxious, but that's irrelevant. When you make claims about the quality of someone's code, it's your responsibility to explain why and offer alternatives, as well as defend yourself in a civil manner against differing opinions. If you can't offer constructive criticism, or accept constructive criticism, be silent or you'll be silenced.
ok theres a row a letters starting at a at from the top of the screen to the bottom...after half a second it changes to the next letter etc when it find the letter it wants it goes a space forward and the process repeats
actually i may be able to do this with the time library and and some simple string function
can i see some tutorials on the two if know any
Oh. I think I know what you want: first print a row os 'a', when the last 'a' in that row is printed move the cursor to the right a little bit and print a row of 'b's. when the last 'b' is printed, move the cursor to the right again and print a row of 'c's. That process continues until the screen is filled with letters.
If that is what you want, it will be fairly simple if you using Turbo C compiler because it supports the gotoxy() function, which moves the text cursor to any desired location. The program will be a bit more difficult using MS-Windows console program and a 32-bit compiler such as Dev-C++ because they do not support gotoxy(), but there are win32 api functions that will perform that task. using a *nix compiler on *nix box, use curses library to do it.
And if it doesn't support the gotoxy, you can always make one, like so -
Just put it in a loop or something. I put a timing class I made here. It's pretty straightforward to use.Code:void GotoXY ( int X, int Y )
{
COORD Cursor_Position;
Cursor_Position.X = X;
Cursor_Position.Y = Y;
SetConsoleCursorPosition( GetStdHandle ( STD_OUTPUT_HANDLE ), Cursor_Position );
}
Or you could just use curses and make it cross platform for fun :D.
I'm sure you do. And I'm sure it is as irrelevant as the need for you to say you find it obnoxious.Quote:
Originally Posted by Prelude
Meanwhile it's a good thing we all finally understand what the OP wanted.
>Do please read the tutorials on this website about for loops.
That's the most common way to do an infinite loop in C++ or C.
Then a fight broke out.
This is a loop that never ends.Code:for( ; ; )
{
// do something
}
Yes it goes on and on my friend.
Some processors started running it,
Not knowing what it was,
and they'll continue running it forever just because.
Now to get back on topic. I'm a bit disappointed in my fellow compatriots. We're arguing about loops. ...again.
>We're arguing about loops. ...again.
Darn, did I miss the last one?:mad:
no thats not what i want what i mean is like it keeps going down the alphabet like for a name and half second it changes the letter
Are you practicing a new language? Do you have an real world examples of what you want? Do you know any programs that do what you're asking?
Depends on if you want it to be portable or not because it's dependent on the operating system.
For windows the conio library will do. With it you will be able to enter and change text at specific positions. If you want it to be portable, use PDCurses instead.
For the timer part of your code you can simulate a sleep function with the help of the time standard library:
Code:void sleep(unsigned int msec) {
clock_t stop_ = msec + clock();
while ( stop_ > clock() ) ; // don't forget the semi-colon
}
ok im gonna try to find the nes game this is in
ill edit when i do but yull need the jnes emu to view it
heh heh sorry i head the description of what i wanted a little bit wrong sorry..
the game is final fantasy2
Where? When you're choosing a name, or you mean the way they display the scrolling text in game?Quote:
Originally Posted by lilhawk2892
I think he means the latter. Fortunately there is a simple way.
Click: https://cboard.cprogramming.com/showthread.php?t=78570
yes ..no sortof
well its not exactly what i wanted but i suppose its good enouph :(
but download final fantasy 2 the first thing you see should be what i want
Well what else did you want it to do?
If you want the top line to disappear, then there is no standard way to do that. You can easily do it with curses or conio.h or window.h, though.
> but download final fantasy 2 the first thing you see should be what i want
- My fellow compatriots are not going to download something so that you can get what you want.
- If you cannot explain coherently what you want to do then it is not worth doing.
- Final Fantasy took a while to develop and is a big [illegal] undertaking to reproduce all by yourself, etc.
you wont download ff2? its a great game well aside from that i think i can figure out what i want now
Not in this lifetime! I like my computer free of viruses and other nasty things you can get from downloading stuff like that.Quote:
Originally Posted by lilhawk2892
How about this?
Code:#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
const int screen_size = 20;
void clrscr(void);
void gotoxy(int x, int y);
int main()
{
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
WORD wOldColorAttr;
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(h, &csbi);
wOldColorAttr = csbi.wAttributes;
SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_INTENSITY);
string display("FINAL FANTASY 2");
clrscr();
int x = 1;
for (string::size_type i=0; i<display.length(); i++)
{
char ch = ' ';
for (;;)
{
for (int y=0; y<screen_size; y++)
{
gotoxy(x, y);
cout << ch << flush;
}
Sleep(50);
if (ch == display[i])
break;
ch++;
}
Sleep(200);
x += 2;
}
cin.get();
SetConsoleTextAttribute(h, wOldColorAttr);
return 0;
}
void clrscr(void)
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT(' '),
dwConSize, coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes,
dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
}
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
!!!! yes it is yes it is yes it is well thank you so much just wow thank you you rock thank you thank you
but wheres the code segment that controls how many letters there are
nvm found it just thank you so much
>but wheres the code segment that controls how many letters there are
If you make the banner to be displayed a string, there's a length() member function you can use to control your for-loop. So it would be:
Since in this case I called the banner striing "display", it's this loop:Code:for (string::size_type i=0; i<name_of_string.length(); i++)
I guess I could have called it title or banner. Those might be better names.Code:for (string::size_type i=0; i<display.length(); i++)