473,383 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Trouble seeing output with visual studio

Hi, I use visual studio for programming in C and when i copy and paste some programs that i know work and produce output, dont do anything. Below is a copy of some random code form someone else that complied but wont work after i type in input


#include <stdio.h>

#define MAXWORDLEN 10

int main(void)
{
int c;
int inspace = 0;
long lengtharr[MAXWORDLEN + 1];
int wordlen = 0;

int firstletter = 1;
long thisval = 0;
long maxval = 0;
int thisidx = 0;
int done = 0;

for(thisidx = 0; thisidx <= MAXWORDLEN; thisidx++)
{
lengtharr[thisidx] = 0;
}

while(done == 0)
{
c = getchar();

if(c == ' ' || c == '\t' || c == '\n' || c == EOF)
{
if(inspace == 0)
{
firstletter = 0;
inspace = 1;

if(wordlen <= MAXWORDLEN)
{
if(wordlen > 0)
{
thisval = ++lengtharr[wordlen - 1];
if(thisval > maxval)
{
maxval = thisval;
}
}
}
else
{
thisval = ++lengtharr[MAXWORDLEN];
if(thisval > maxval)
{
maxval = thisval;
}
}
}
if(c == EOF)
{
done = 1;
}
}
else
{
if(inspace == 1 || firstletter == 1)
{
wordlen = 0;
firstletter = 0;
inspace = 0;
}
++wordlen;
}
}

for(thisval = maxval; thisval > 0; thisval--)
{
printf("%4d | ", thisval);
for(thisidx = 0; thisidx <= MAXWORDLEN; thisidx++)
{
if(lengtharr[thisidx] >= thisval)
{
printf("* ");
}
else
{
printf(" ");
}
}
printf("\n");
}
printf(" +");
for(thisidx = 0; thisidx <= MAXWORDLEN; thisidx++)
{
printf("---");
}
printf("\n ");
for(thisidx = 0; thisidx < MAXWORDLEN; thisidx++)
{
printf("%2d ", thisidx + 1);
}
printf(">%d\n", MAXWORDLEN);

return 0;
}




Here's the output of the program when given its own source as input:

113 | *
112 | *
111 | *
110 | *
109 | *
108 | *
107 | *
106 | *
105 | *
104 | *
103 | *
102 | *
101 | *
100 | *
99 | *
98 | *
97 | *
96 | *
95 | *
94 | * *
93 | * *
92 | * *
91 | * *
90 | * *
89 | * *
88 | * *
87 | * *
86 | * *
85 | * *
84 | * *
83 | * *
82 | * *
81 | * *
80 | * *
79 | * *
78 | * *
77 | * *
76 | * *
75 | * *
74 | * *
73 | * *
72 | * *
71 | * *
70 | * *
69 | * *
68 | * *
67 | * *
66 | * *
65 | * *
64 | * *
63 | * * *
62 | * * *
61 | * * *
60 | * * *
59 | * * *
58 | * * *
57 | * * *
56 | * * *
55 | * * *
54 | * * *
53 | * * *
52 | * * * *
51 | * * * *
50 | * * * *
49 | * * * *
48 | * * * *
47 | * * * *
46 | * * * *
45 | * * * *
44 | * * * *
43 | * * * * *
42 | * * * * *
41 | * * * * *
40 | * * * * *
39 | * * * * *
38 | * * * * *
37 | * * * * *
36 | * * * * *
35 | * * * * *
34 | * * * * *
33 | * * * * *
32 | * * * * *
31 | * * * * *
30 | * * * * * *
29 | * * * * * *
28 | * * * * * * *
27 | * * * * * * *
26 | * * * * * * *
25 | * * * * * * * *
24 | * * * * * * * *
23 | * * * * * * * *
22 | * * * * * * * * *
21 | * * * * * * * * *
20 | * * * * * * * * *
19 | * * * * * * * * *
18 | * * * * * * * * *
17 | * * * * * * * * *
16 | * * * * * * * * *
15 | * * * * * * * * *
14 | * * * * * * * * * *
13 | * * * * * * * * * *
12 | * * * * * * * * * *
11 | * * * * * * * * * *
10 | * * * * * * * * * *
9 | * * * * * * * * * * *
8 | * * * * * * * * * * *
7 | * * * * * * * * * * *
6 | * * * * * * * * * * *
5 | * * * * * * * * * * *
4 | * * * * * * * * * * *
3 | * * * * * * * * * * *
2 | * * * * * * * * * * *
1 | * * * * * * * * * * *
+---------------------------------
1 2 3 4 5 6 7 8 9 10 >10

I can get any of this to show up.

Thanks for the help.
Feb 4 '10 #1
2 1672
Banfa
9,065 Expert Mod 8TB
Have you tried running it by pressing <ctrl>-F5?
Feb 4 '10 #2
The crtrl f5 is what i always use, and usually it works. Every other program i have ran worked fine except for ones that seem to have a lot f output in the final solution.
Feb 5 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Tamir Khason | last post by:
Following the code: Assembly myAssembly = Assembly.LoadFrom(FileName); foreach (Type myType in myAssembly.GetTypes()) {Do_whatever()}
2
by: Peter Kirk | last post by:
Hi I am "playing" with some simple aspects of C# with Visual Studio. All I would like to know right now is how do I get the Console.Write method to write its output in the Visual Studio...
3
by: lasmit | last post by:
I am having some troubles with a project I am working on not building correctly. I converted an old ASP project to .Net and then have been adding pages to the project in C#. This all works ok,...
2
by: JezB | last post by:
I'm compiling an old C program within Visual Studio to give me the advantages of debugging within this environment. I'm building it as a Console application using C++ as the language. It compiles...
5
by: Verane | last post by:
Hi, I have read the thread named "Could not copy temporary files to the output directory" on this newsgroup. And I have the same symptoms on my machine. But I didn't find any solution suitable for...
4
by: Michael Maes | last post by:
Hello, I want to add a date (ShortDateString) to a custom template-file (Class). I use: a.. b.. c.. But I can't find anythig on a date (something like: )
2
by: RSH | last post by:
Hi, I am having a little trouble with a Visual Studio project. I moved and existing project to a Network share and now when I go to run the project in Debug mode I get an error saying "The...
5
by: mlg1906 | last post by:
I'm developing an intranet site in ASP.NET 2.0 but I can't seem to connect to the DB from within my code. I've created a .vb class that houses a private Connection() that other functions within the...
3
by: TC | last post by:
I'm trying to debug a console application, but I can't see the console output. I've seen many references which say that console output is supposed to appear on the Output window when the...
0
by: franzbrown | last post by:
Most of the threads I am using in my C# application have names (Thread.Name = ). When I am debugging my application within VS 2005, I have a UI to stop my application and the threads it started....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.