Spaces in Console

Started by
52 comments, last by XDarkScar 21 years ago
you mean you want to add two strings?

std::string bob;std::string smith;bob = "bob";smith = "smith";cout << bob + smith;  // not 100% sure std::string has a + operator, but it should 


if you want a space, you can either put a space after bob, before smith, or this might work, depends on if std::string''s + operator accepts an std::string or a const char *, it might work anyway: cout << bob + " " + smith;
Advertisement
quote:Original post by Lektrix
    FullScreenMode();

How would you go from full screen to windowed, and how would you check to see what the current state is? Thanks.
As you probably know, if you open up the command prompt and press alt + enter, the window will change from normal to full screen mode or full screen to normal mode. Basically, all the function does is creates a keyboard event / sends the keys to the program, i.e. sort of pretends that the user is holding alt + enter and then letting go of them. I''m not sure whether this is the "proper" way to do it, but it seems like a little hax.

Because alt + enter does the inverse - i.e. if you press alt + enter whilst in normal mode, it changes the command prompt to full screen mode, and vice versa - you can use the same command to change between modes. I would, then, change the function name:


#include <iostream>
#include <windows.h>

void ChangeScreenMode();

void ChangeScreenMode()
{
keybd_event(VK_MENU, 0x38, 0, 0); // hold alt key down
keybd_event(VK_RETURN, 0x1c, 0, 0); // hold enter key down
keybd_event(VK_RETURN, 0x1c, KEYEVENTF_KEYUP, 0); // release enter
keybd_event(VK_MENU, 0x38, KEYEVENTF_KEYUP, 0); // release alt
}

int main()
{
ChangeScreenMode(); // if started in normal, now in full screen - vice versa
std::cout << "Welcome to full screen mode!\n\n";
system("PAUSE");

ChangeScreenMode(); // if was in full screen, now in normal - vice versa
std::cout << "Welcome to normal mode!\n\n";
system("PAUSE");

return 0;
}


As I said, as far as I can see this is a hax. I''m sure that there must be some proper Windows API functions for you to change the mode and check the mode. I would recommend that you have a look on MSDN for these functions; I can''t be bothered.

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
Try this...

  char name[40];cin.getline(name, 40);cout << name;  
----------------------------------------------------------------------------------------------------------------------"Ask not what humanity can do for you, ask what you can do for humanity." - By: Richard D. Colbert Jr.

This topic is closed to new replies.

Advertisement