tags:

views:

94

answers:

5

hello every body i am beginner in Anci c programming here is the description for my program my program first asks user to press any key then a new console is opened and the user inputs any number he want then the console is closed and the number he typed is printed in the parent console ,i hope this clear and thanks for reply

so i want the function that opens a new console i am using Code::Blocks gcc compiler under win 7

A: 
system("cmd");

should do the trick

ammoQ
This assumes Windows. system("xterm"); is a safe bet under Linux.
0x6adb015
Erm, in what universe is that going to "do the trick"? And I'm not sure that counts as "ANSI C".
Gian
can you tell the header file please
mohammed sameeh
A: 

There is no such command/function, because it would be operating-system-dependent

BlaXpirit
+3  A: 

"ANSI C" doesn't know there is such a thing as "consoles" or "windows". This is almost certainly going to depend on the operating system and/or windowing environment being used, as well as any third-party libraries being used to drive these kinds of operations. Maybe something like ncurses would be helpful here, but there's no way of knowing without more specific information.

Gian
sorry Lack of clarity for my question the program first ask user to press any key thenthen a new console is opened and the user inputs any number he want then the console is closed and the number he typed is printed in the parent console ,i hope this clearand thanks for reply
mohammed sameeh
@mohammed sameeh - you should edit your question to contain the comment above.
bstpierre
+1  A: 

ANSI C doesn't have a concept of "windows". That's an operating system concept outside the area of the C language.

James Curran
+1  A: 

As people have mentioned, this doesn't make sense for ANSI C. For Windows, you'll need to be more specific about what you want.

If you're writing a console application (done automatically if you're using main, or if you explicitly pass the /SUBSYSTEM:CONSOLE flag to the linker), you don't need to do anything special. Running your application from a windowed application will spawn a console window for you. Running it from an existing console window will reuse that one.

If you're writing a windowed application (done automatically if you're using WinMain, or if you explicitly pass the /SUBSYSTEM:WINDOWS flag to the linker), you can use AllocConsole. See the Creation of a Console article from MSDN. (I think you also should be able to do that if you're writing a console application and never want to reuse an existing console, but I'd have to say that doing so would be very user-unfriendly.)

jamesdlin