Basic C Programming Question

This is a discussion on Basic C Programming Question within the C Programming forums, part of the General Programming Boards category; Hello all, First off I would like to say that I am a novice programmer and am just starting to ...

  1. #1
    Registered User
    Join Date
    Dec 2012
    Location
    New Jersey, USA
    Posts
    2

    Question Basic C Programming Question

    Hello all,

    First off I would like to say that I am a novice programmer and am just starting to learn the language. This is also my first time on this board (which I hope to frequent quite often!) so if I am doing something wrong please let me know!

    I am doing all of my programming in linux. That being said, I have done some very simple programs already and have ran into what seems to be a very simple problem on my current one.

    I am trying to create a "greedy" program that counts the minimum number of coins used to create the amount that the user inputs. I keep getting "expected identifier or '('" errors when i try to compile in gcc using clang.

    Here is my code and the error that I receive:

    Code:
    #include <stdio.h>
    #include <math.h>
    
    
    /**************
    *Greedy
    *Objective: To determine the least amount of coins used to represent the user's input
    *The result will be the least possible amount of coins
    ***************/
    
    
    int main(void);
    {
        int count = 0;
        float change;
    
    
    do
    {
        printf("O hai! How much change is owed?\n");
        change = GetFloat();
    }
    while(change < 0);
    
    
    return 0;
    }
    Through using clang I enabled my program to stop running and tell me where and when an error happens. This is what I get when I try to compile:

    Code:
    clang -ggdb3 -O0 -std=c99 -Wall -Werror    greedy.c  -lm -o greedy
    greedy.c:12:1: error: expected identifier or '('
    {
    ^
    1 error generated.

    I have looked at the different tutorials and even back at my past programs that have all started like that with no errors, and cannot seem to grasp what is happening. I have been stuck on this for 3 days now. Any guidance or help would be greatly appreciated!!!
    Last edited by goldeneye007; 12-06-2012 at 04:59 PM.

  2. #2
    Registered User
    Join Date
    Dec 2012
    Location
    New Jersey, USA
    Posts
    2
    Nevermind! I finally figured it out, added a ";" after int main(void)...

    and then I have much more tweaking to do. I guess it's true that you never really see the answers to your questions until you ask!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. basic bash programming question
    By Jimb0 in forum Linux Programming
    Replies: 4
    Last Post: 05-05-2011, 10:55 PM
  2. Basic c programming help
    By benrogers in forum C Programming
    Replies: 12
    Last Post: 01-24-2011, 04:01 PM
  3. A basic math programming question
    By hebali in forum C Programming
    Replies: 38
    Last Post: 02-25-2008, 03:18 PM
  4. Just a basic question about game programming
    By need4speed in forum Game Programming
    Replies: 5
    Last Post: 01-20-2008, 02:24 AM
  5. basic C-programming Q
    By slyonedoofy in forum C Programming
    Replies: 2
    Last Post: 10-30-2002, 08:54 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21