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

Join 107,702 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 978 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! 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
post 2 Jul, 2008 - 11: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

Go to the top of the page


gabehabe
post 2 Jul, 2008 - 11:49 AM
Post #2


T3H R0XX0R!

Group Icon
Joined: 6 Feb, 2008
Posts: 2,300



Thanked 44 times

Dream Kudos: 1450

Expert In: C, C++

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 - 11:54 AM
User is offlineProfile CardPM

Go to the top of the page

chaoticabyss99
post 3 Jul, 2008 - 10:09 PM
Post #3


D.I.C Head

**
Joined: 14 Jun, 2008
Posts: 59


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

Go to the top of the page

Reply to this topicStart new topic
Time is now: 8/30/08 01:50AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month