Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,478 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,609 people online right now. Registration is fast and FREE... Join Now!




visual c++ 2008 Express output screen goes away after build.

 
Reply to this topicStart new topic

visual c++ 2008 Express output screen goes away after build., I need to print the output file for my prograns after running them and

lclewis
2 Jul, 2008 - 10:32 AM
Post #1

New D.I.C Head
*

Joined: 23 Nov, 2007
Posts: 1


My Contributions
cpp

#include <stdio.h>
#include <iostream>

int main(int argc, char *argv[])

{
int c, i, letter[26], digit[10];
FILE *ifp, *ofp;

if (argc !=3)
{
printf("\n%s%s%s\n\n%s\n%s\n\n",
"Usage: ", argv[0], " infile outfile",
"The uppercase letters in infile will be counted.",
"The results will be written in outfile.");
exit(1);
}
ifp = fopen(argv[1], "r");
ofp = fopen(argv[2], "w");
for (i = 0; i < 36; ++i) // initialize array to zero
letter[i] = 0, digit[i] = 0;
while ((c = getc(ifp)) != EOF)
if (c >= 'A' && c <= 'Z') // search for uppercase letters
++letter[c - 'A'];
else if (c >= '0' && c <='9') // count numbers in file
++digit[c - '0'];
for (i = 0; i < 36; ++i)
{
if (i % 3 == 0)
putc('\n', ofp);
fprintf(ofp, "%c occured %3d times", 'A' + i, letter[i], '0' + i, digit[i]);
}
putc('\n', ofp);
}


Mod Edit: Please use code tags when posting your code. Code tags are used like so => code.gif

Thanks,
PsychoCoder smile.gif
User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Visual C++ 2008 Express Output Screen Goes Away After Build.
2 Jul, 2008 - 10:49 AM
Post #2

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,539



Thanked: 98 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
Just try holding the window open, you could use cin.get(); but there are a number of ways to do it smile.gif

This post has been edited by gabehabe: 2 Jul, 2008 - 10:54 AM
User is offlineProfile CardPM
+Quote Post

chaoticabyss99
RE: Visual C++ 2008 Express Output Screen Goes Away After Build.
3 Jul, 2008 - 09:09 PM
Post #3

D.I.C Head
**

Joined: 14 Jun, 2008
Posts: 92


My Contributions
QUOTE(lclewis @ 2 Jul, 2008 - 11:32 AM) *

cpp

#include <stdio.h>
#include <iostream>
#include <conio.h> //header to keep execution window open

int main(int argc, char *argv[])

{
int c, i, letter[26], digit[10];
FILE *ifp, *ofp;

if (argc !=3)
{
printf("\n%s%s%s\n\n%s\n%s\n\n",
"Usage: ", argv[0], " infile outfile",
"The uppercase letters in infile will be counted.",
"The results will be written in outfile.");
exit(1);
}
ifp = fopen(argv[1], "r");
ofp = fopen(argv[2], "w");
for (i = 0; i < 36; ++i) // initialize array to zero
letter[i] = 0, digit[i] = 0;
while ((c = getc(ifp)) != EOF)
if (c >= 'A' && c <= 'Z') // search for uppercase letters
++letter[c - 'A'];
else if (c >= '0' && c <='9') // count numbers in file
++digit[c - '0'];
for (i = 0; i < 36; ++i)
{
if (i % 3 == 0)
putc('\n', ofp);
fprintf(ofp, "%c occured %3d times", 'A' + i, letter[i], '0' + i, digit[i]);
}
putc('\n', ofp);

_getch(); //used to keep execution window open
}


Mod Edit: Please use code tags when posting your code. Code tags are used like so => code.gif

Thanks,
PsychoCoder smile.gif




I have added the header "#include <conio.h>" and also "_getch();" at the end of the code. I am just learning C++, but I have been using this in all of my programs and it seems to work.

(Also, I have received a lot of help from people at D.I.C., that I was hoping I would be able to give back -- even if it's just a little.)

Hope this works for you. smile.gif


User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 06:17PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month