Results 1 to 5 of 5

Thread: [RESOLVED] Simple C error!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Location
    Australia, Melbourne
    Posts
    29

    Resolved [RESOLVED] Simple C error!

    C Code:
    1. #ifndef _readIn_h
    2. #define _readIn_h
    3.  
    4. void readIn(polynomial*, settings*);
    5.  
    6. #endif

    polynomial and settings are typedef structs in a header file that readIn.C uses. So i shouldnt have to include the header file in this header file right?

    Says it expects ')' before the '*' token... but it is fine and so is all other files... no other errors so i am a little confused!

  2. #2
    Hyperactive Member Max Peck's Avatar
    Join Date
    Oct 2007
    Posts
    384

    Re: Simple C error!

    Without knowing any more about this, it appears to me that you don't have a definition for "polynomial" and "settings" defined anywhere in the scope here. The general form of your prototype seems right but the compiler doesn't recognize the two keywords.

    -Max
    The name's "Peck" .... "Max Peck"

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Location
    Australia, Melbourne
    Posts
    29

    Re: Simple C error!

    adt.h
    C Code:
    1. #include <stdio.h>
    2. #include <stdlib.h>
    3.  
    4. /* ONLY ARRAYS NEED TO BE POINTERS */
    5.  
    6. /* Polynomial Structure */
    7. typedef struct
    8. {
    9.     int degree;
    10.     double* coe;
    11.     double constant;
    12. } polynomial;
    13.  
    14.  
    15. /* Settings Structure */
    16. typedef struct
    17. {
    18.     int upper;
    19.     int lower;
    20.     double iterations;
    21. } settings;
    22.  
    23.  
    24. /* Results Structure */
    25. typedef struct
    26. {
    27.     double stdDev;
    28.     double stdErr;
    29.     int Fi;
    30.     int Fav;
    31.     double solution;
    32. } results;

    readin.c
    C Code:
    1. #include <stdio.h>
    2. #include <math.h>
    3. #include <stdlib.h>
    4. #include "adt.h"
    5.    
    6. void readIn(polynomial* p, settings* s)
    7. {
    8.       /* reads in all data */
    9.       /* didn't copy it for length reasons */
    10.       /* had no errors though */
    11. }

    readin.h
    C Code:
    1. #ifndef _readIn_h
    2. #define _readIn_h
    3.  
    4. void readIn(polynomial*, settings*);
    5.  
    6. #endif

    These are the related files and code not sure if this helps you?... i might try using a different IDE for this assignment if i can if i cant figure it out by end of today.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Location
    Australia, Melbourne
    Posts
    29

    Re: [RESOLVED] Simple C error!

    Ooooo appears the error was in the main.c file... using Quincy and the formatting of errors is a bit weird thought there was only one... but i had included readIn.h before adt.h and it didn't like that so done...

    C Code:
    1. #include "adt.h"
    2. #include "readIn.h"

    Fixed

  5. #5
    Hyperactive Member Max Peck's Avatar
    Join Date
    Oct 2007
    Posts
    384

    Re: [RESOLVED] Simple C error!

    Glad we could help! ;-)
    The name's "Peck" .... "Max Peck"

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width