Solved

New to C:  Looking for compiler

Posted on 2000-05-05
14
242 Views
Last Modified: 2013-12-14
I am learning C from a book.  I am currently using the Visual C++ 6 (visual studio) compiler..however, approximately 50% of the programs are running.  

Do I need a new compiler?  

One other thought I had was that I am using the #include <stdio.h> statement..and it is rarely recognized.  If this is the problem..what do I need to do to correct it?

Thanks,
-A
0
Comment
Question by:ambulance
  • 4
  • 2
  • 2
  • +5
14 Comments
 
LVL 16

Expert Comment

by:imladris
ID: 2782533
I assume that your real problem is the 50% of the programs that are not running. Remember that 99% of the time the problem with a program not running lies with the programmer, not the compiler. There is, offhand, no reason to believe Visual C++ 6 is incapable of compiling the code.

stdio not being  recognized would certainly cause quite a lot of trouble. Exactly what error message do you get?

0
 

Author Comment

by:ambulance
ID: 2782566
The only information the Error Message gives me is that 'stdio.h is not recognized'.  No more specific than that.  

Here is an example:  pretty simple, compiles okay, builds the .exe okay, but I go to run the .exe, get nothing.

Any ideas?  Am I doing something else wrong?

#include <stdio.h>

int x,y;

main()
{
      for (x = 0; x < 10; x++, printf ("\n"))
            for (y=0; y<10; y++)
                  printf("X");
                  
      return 0;
}
0
 
LVL 22

Expert Comment

by:cookre
ID: 2783235
Go to Tools/Options/Directories. Select the appropriate 'Platform' then, under 'Show directories for:', select 'Include files'.

Make sure that the correct include directoy is listed.  It's usually <CompilerInstallPath>\include.

If that directory is not in the above list, add it.  If it is in the list, look in the directory to make sure stdio.h is there.
0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2783958
ambulance: How are you running the EXE file? If you just double-click it, or run it from the Visual Studio IDE, you might see a momentary flash as a console window opens, displays your Xs, then closes again--on a very fast system you might not even see this, so you'd think nothing happened. Try running a command prompt, changing to the directory the compiled program is in, and run it from there--since the window is already open you should see the results!
0
 
LVL 2

Expert Comment

by:CSuvendra
ID: 2784543
Visual C++ will recognize stdio.h only if the extension of the file you create is .c. By default it gives the extention .cpp and assumes you are coding in C++ and not in C, and will look for iostream.h and stuff. When creating the files, just explicitly mention the file name as .c, say you are creating 'foobar.exe', so make the program as 'foobar.c' and headers as 'foobar.h', then compile.

And about running the program, you will be better off if you open a DOS prompt, change to the directory where the executable is created, and run from command line.

Suvendra
0
 
LVL 33

Expert Comment

by:hongjun
ID: 2786961
When you run your that code a window will pop up but will then close almost immediatelty.
This is absolutely normal. To see the output of the result, you can:
1) put a getchar() statement just at the end of your program so that the window will not close but will once you hit the return key.
2) Run the program in dos.

As for the problem in including the stdio.h file, I think you should re-install VC.

hongjun
0
 
LVL 16

Expert Comment

by:imladris
ID: 2788715
hongjun,

what information did you add that justifies "answering" the question?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:ambulance
ID: 2788834
I have checked out a few things.  I still don't have an answer yet...hopefully this will help narrow things down so I can figure out what I'm doing wrong.

1.  I did notice that some of the programs were running very fast. I was able to run them from DOS at a slower rate.  However, this only worked with the programs that were initially working.  

2.  All the C programs do have the extension .c.  However, I have not set any .h headings.  How do I know when I need to do that?

3.  I did go to Tools/Options/Directories.  The only platform available was Win32.  'Include Files' was already selected, but I was unable to locate the <CompilerInstallPath>\Include.  Where would I find that?  If that is supposed to be in the listbox still in Tools/Options/Directories, it isn't displaying.

4.  The getchar() statement didn't do anything different than what was already happening.  

Above, I posted a piece of code, that came from the text book, that won't run.  I have since come across a program that calls to #include <system.h> and that is causing a fatal compile error.  I am a VB programmer and am totally new to this syntax.  

Any additional help would be greatly appreciated.  I hope I'm not being totally blonde here.  You guys are helping a lot!

-A
0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2790119
What happened when you tried to run the program from a command prompt, like I suggested?
0
 
LVL 2

Expert Comment

by:CSuvendra
ID: 2790582
Well, about your point 2, you may need custom .h files, or Header files, if you need to pre declare the prototypes for functions you will be using across multiple C sub programs, going to give you one executable.

Can you also check the following. I guess you are doing it correctly, but when the program doesn't run on DOS, did you make 'console applications' for those - that is you are creating a new 'Console App' ?

Find out where stdio.h is installed in your system. For my convenience I am assuming that it is installed in C:\Visualdev\VC++\include. So change the code

#include <stdio.h>

to

#include "C:\Visualdev\VC++\include\stdio.h"

Check if the compiler can recognize that now. If it can't we need to check what other options can be there.

Suvendra
0
 
LVL 3

Accepted Solution

by:
sburck earned 50 total points
ID: 2800553
If you're learning C now for the first time, most of the programs you are running will be DOS type (command - line) stuff.  Borland is giving away their old DOS based C++ compiler free, to all takers.  It's a great way to learn the languages C & C++, especially with the nice help files that come with it.

Just navigate to:

http://www.borland.com/bcppbuilder/freecompiler/
0
 
LVL 1

Expert Comment

by:Vinay
ID: 2804235
hello
i am c faculty & was shocked to hear that u r doing c under VC++; k i will try to explain u, see boss c was the first fundamental language & it has got some standards of ANSI called as ANSI C standards(here u will get use of stdio.h & all)& by using these standards C (specifically C) compilers r created which supports C programmes on same platforms. Then C++ is OOP language which can be called as superset of C & most of the compilers support C as well as C++ & the difference comes at the time of compilation i.e. if ur extension is ".c" like exampple.c then it will be compiled by C compilers but if it is ".cpp" then C++ compiler will take care of that. Difference is C++ comp. is little more strict about declaration where C is not as C++ is OOP & it requires everything to be declared before use. Now most of the C programmes can be compiled & linked under C++ comp. also but i said most of the----- there r always exception.
Now about VC++ -- people use to call it as system level programming language but frankly speaking its a tool -- better to say a very powerful tool for system level programming but only made for <<<<<windows>>>>> so it has got some platform specific code which is being generated by VC++ comp by internelly using C++ compiler just for windows so if u go for that u must be master in C & C++ to understand internal use of all these things. So frankly better u go for any C IDE like TC or Borland C & i think they r free now a days. If not just tell me & i will upload complete c for u & then u can get it downloaded! ok?
if u need any other further guidance then mail me & we can have chating so that if possible i can clear ur fundas online
my email - vinusa500@mailcity.com
Love Vinay
0
 

Author Comment

by:ambulance
ID: 2804982
Whoa!  This is the last time I take a few days off of work!!  Thanks for all the responses.

I tried the Borland compiler and the 'miracle' compiler with not much more luck.  

But some luck nonetheless.  I am now up to a 75% run success rate.  I am happy about that.  I am assuming, that since I do have more running that the ones that don't have some typo in there that I missed the first few times around.

Now, I would like to give points to Sburk and CSuvendra.  They have been the most helpful.  I will give Sburk these points and post another questions to give points to CSuvendra.  Unless you know of a better way.

Thanks so much!!
-A
0
 

Author Comment

by:ambulance
ID: 2804985
thankks a lot!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now