Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Need help: problem with the program's display...
Closed Thread
Old 09-13-2006, 10:51 AM   #1 (permalink)
 
Junior Techie

Join Date: Oct 2004

Posts: 60

Fabyfakid

Default Need help: problem with the program's display...

I've started using Dev C++ to practice the exercises at home. One of those was to show the classes I'm taking this semester, and print the screen as evidence that the code worked. So I made the code, and when I compiled/ran it, the display window appeared for less than a second before disappearing, not giving me time to "print screen" it. The code looks like this (note - the comments and a couple of other things are in spanish, but the rest is C, lol):

Quote:

#include <stdio.h>
/*Asignacion de INGE 3016 por my name*/
int main ()

{

printf("Programa de clases:\n\t");
printf("Algoritmos y Programacion (INGE 3016) LWV 8:35 - 9:25\n\t");
printf("Fisica I (FISI 3171) LMWV 9:40 - 10:30\n\t");
printf("Engineering Mechanics (INGE 3035) LWV 11:50 - 12:40\n\t");
printf("Fundamentos del Volleyball (EDFI 3225) LW 12:55 - 1:45\n\t");
printf("Calculo II (MATE 3032) LWJV 2:00 - 3:00\n\n");
printf("Clases a tomar el proximo semestre:\n\t");
printf("Calculo III (MATE 3063)\n\t");
printf("Electrical System Analysis I (INEL 3105)\n\t");
printf("Engineering Materials (INGE 4001)\n\t");
printf("Fisica II (FISI 3172)\n\t");
printf("Lab. Fisica I (FISI 3173)");

}
What could be wrong? How can I make the display window that "prints" the output stay? Thanks in advanced for the help...
Fabyfakid is offline  
Old 09-13-2006, 10:56 AM   #2 (permalink)
 
Junior Techie

Join Date: Oct 2004

Posts: 60

Fabyfakid

Default

Forgot to mention, I already handed this. I used the command prompt to execute it. But still, it would be easier if it appeared automatically (and stayed there) as I ran it in the IDE. Thanks again.
Fabyfakid is offline  
Old 09-13-2006, 01:11 PM   #3 (permalink)
 
Newb Techie

Join Date: Sep 2006

Posts: 6

jorgebucaran

Default

Hola amigo!

Solo querÃ*a aprovechar la oportunidad de recomendarte Visual C++ Express Edition. No soy partidario de hacerle propaganda a Microsoft pero definitivamente no puedo sino opinar que el producto es bueno, muy satisfactorio y además gratis.

Sobre tu pregunta, debes añadir un comando para detener el flujo del programa antes de que culmine. Si estas utilizando el sistema operativo Windows, añade en la cabecera #include <process.h> y utiliza la maravillosa instruccion system("pause") para detener la pantalla.

Si eres un poco perspicaz notarás que el comando pause es propio del sistema de lÃ*nea de comandos de Windows (conocido anteriormente como DOS). El punto es que puedes pasarle a la instrucción system() cualquier cadena con los comandos conocidos de DOS, tales como: "cls", "pause", etc.

Buena suerte!
jorgebucaran is offline  
Old 09-13-2006, 06:59 PM   #4 (permalink)
 
Junior Techie

Join Date: Oct 2004

Posts: 60

Fabyfakid

Default

Jorge, gracias por la disposicion de ayudarme. Me puse a buscar mas info en otros foros, y aprendi que se debe anadir "getchar();"
despues de todo lo demas.
Fabyfakid is offline  
Old 09-13-2006, 11:22 PM   #5 (permalink)
 
Newb Techie

Join Date: Sep 2006

Posts: 6

jorgebucaran

Default

Muy bien!

Si de verdad te gusta esto de la programación, cualquier ayuda que necesites en el futuro con gusto te podrÃ*a ayudar. Mi e-mail es jbucaran@gmail.com

Hasta luego!
jorgebucaran is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On