I was just wondering if there was another way to out put text besides cout? I know this probablt sounds weird because cout works perfectly fine and stuff, but I just want to know if all of the input/output has to be done in a cprompt window? Dose anyone know of an alternative. All help is appreciated!! ^_^

That depends on the libraries you're using. The standard library also lets you output to files and to the stderr output stream.

Other libraries exist that let you make windows in the windowing system and send text over a network.

What you can use depends on what you have installed; what you can install depends on what operating system you are using.

I have Windows Vista and my compiler is Dev-Cpp. What is the stderr output stream?

printf is your best bet for a cout alternative. It is from the cstdlib library (for C++, stdlib.h for C)

printf() and cout both send data to the same place.

C++ only knows of the standard input, output, and error channels, and any other files/sockets/devices/etc. you explicitly open.

If you want to display things differently on Windows, you have to go through the Win32 API. For example:

#include <windows.h>

int main() {
  MessageBox( NULL, TEXT( "Hello world!" ), TEXT( "A greeting" ), MB_OK );
  return EXIT_SUCCESS;
  }

There are all kinds of ways to display textual data in Windows: message dialogues, labels, edit boxes, etc.

Hope this helps.

>I was just wondering if there was another way to out put text besides cout?
You can use cerr, it's normally pointed to the same location as cout. You can also use the standard C output functions, but that can open an unexpected can of worms when it comes to synchronization with the C++ streams. You can also do it manually:

const char *p = "This is a test";

while ( *p != '\0' )
  std::cout.put ( *p++ );

>I just want to know if all of the input/output has to be done in a cprompt window?
Of course not. You can define a stream for any source/destination that produces results in a sequential manner. A good example is file streams and string streams, and C++ provides those for you. You can also write your own streams. For example, I recently wrote a stream for database queries.

I was just about to post a similar (almost exact) question to this, so why not post it here...

Is there any actual code that can be used to send output to the console (in c++ still) without calling any sort of premade "out to screen" function?
I assume that to do this you would need to use assembly or something; this is (obviously) bot c++

>without calling any sort of premade "out to screen" function?
The realistic answer is that you can't do that[1] on a modern system due to protection. You'd have to go through a driver at the very least, and ideally a system API. Either way you're calling functions in a practical solution.

[1] At least not without some serious bare-backing.

When a C++ program is running, the following four built-in streams are automatically opened:

Stream Meaning Default Device Corresponding C stream
cin standard input keyboard stdin
cout standard output screen stdout
cerr standard error output screen stderr
clog buffered version of cerr screen


<snip>

Hiii am an amateur programmer.... I was trying to create a memory game... already started a thread on it... now I am in need of an input ouput alternative for cin/cout... cin waits till the user enters the answer... but is there any input method which wont wait for the user?.... the user shouldn't be allowed to enter his answer after the allotted time.. so any other input methods?


please help me friends

and what are the main differences between cin/cout and printf()?? printf()is the one used for output,right?...which is the one for inputting??...

cin waits till the user enters the answer... but is there any input method which wont wait for the user?

Neither standard C not C++ support such a capability (over-simplistically, because C and C++ are designed to work on platforms without a keyboard, and such capabilities generally amount to reading keystrokes directly from a keyboard).

To do this, you will need to read the documentation for your operating system and non-standard library features supported with your compiler.

which input/output methods are commonly used by professionals? ?

A professional uses whatever methods are appropriate for the task at hand; if a task that's outside his/her experience comes up, then a professional will investigate and find an appropriate method. If the first method doesn't work quite right (eg doesn't meet the key user requirements) then a professional will look for alternate methods.

Sorry I've missed the last week (more or less).

To do fancy stuff with the console use the Curses library.

NCurses
Platform: POSIX
Where: http://www.gnu.org/software/ncurses/
Notes:
If you are using Unix, chances are you have already got NCurses installed.
If you are on Linux, you will probably need to sudo apt-get install ncurses-dev (or whatever your equivalent is).
Link with:
normal systems: -lcurses Solaris: -lncurses

PDCurses
Platform: DOS, Win32, OS/2, Plan 9, ...
Where: http://pdcurses.sourceforge.net/
Notes:
It works well with any PC compiler, but you can get precompiled binaries that work with MinGW over at their sourceforge download site.
Link with: -lpdcurses PDCurses is a port of NCurses, but there are some small differences. If you stay away from extras like window-resize notification and mouse-handling then you'll have no troubles.

The NCurses Programming HOWTO

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.