can anyone see anything wrong with this code

This is a discussion on can anyone see anything wrong with this code within the C++ Programming forums, part of the General Programming Boards category; Code: display(int student_id, string first_name, string last_name, string phone, string street, string street1, string street2, string street3, string city, string ...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    3

    can anyone see anything wrong with this code

    Code:
    display(int student_id, string first_name, string last_name, string phone, string street, string street1, string street2, string street3, string city, string state, string zip, int admitted, float gpa, string courses);
     
    add(int student_id, string first_name, string last_name, string phone, string street, string street1, string street2, string street3, string city, string state, string zip, int admitted, float gpa, string courses);
    
    remove(int student_id, string first_name, string last_name, string phone, string street1, string street2, string street3, string city, string state, string zip, int admitted, float gpa, string courses);
    can anyone see anythign wrong witht these 3 lines of code?? i get 3 seperate error messages when compiling it for each line. the message is:

    58 C:\Documents and Settings\Owner\My Documents\File Processing\assignmetn1.cpp syntax error before `,' token

    im using dev c++t to build and compile the program

  2. #2
    Registered User
    Join Date
    Nov 2004
    Posts
    25
    Well, assuming these are proto-types of functions, you forgot to set each functions return type, but I'm a beginner so I'm probably just not making any sense. =\

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    3

    return type

    i do have prototypes. these are simply function calls so i dont need a return value. all 3 are void functions as well

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    I fixed your code tags, although in this case, it probably hasn't helped. In future, code tags etc., here use square brackets not angle brackets a la html.

    Your third function has one less parameter then the others, "string street" is missing.

    Errors like that are often associated with the code around the lines. They are also long, some older compilers used to complain if lines were too long. Otherwise, withiut more code I can't say.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    The root of the error is that there are simply more parameters than you can properly keep track of. This should be at least a struct, better yet a class (although you might not yet be that far).
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    >>i do have prototypes. these are simply function calls

    Then I'd recommend removing the type indications before each parameter in the function call list of parameters.

    //prototypes
    void display(int student_id, string first_name, string last_name);
    void add(int student_id, string first_name, string last_name);
    void remove(int student_id, string first_name, string last_name);

    //initialize parameters
    int student_id = 2314;
    string first_name = "Jane";
    string last_name = "Smith";

    //call function using intialized parameters
    display(student_id, first_name, second_name);
    add(student_id, first_name, second_name);
    remove(student_id, first_name, second_name);

    //don't forget to define the functions somewhere, too
    Last edited by elad; 12-07-2004 at 09:33 AM.

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    If you're going to have so many parameters, at least fold the lines for readability
    Code:
    display(int student_id, string first_name, string last_name, string phone,
        string street, string street1, string street2, string street3,
        string city, string state, string zip,
        int admitted, float gpa, string courses);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what is wrong in this simple code
    By vikingcarioca in forum C Programming
    Replies: 4
    Last Post: 04-23-2009, 07:10 AM
  2. what is wrong with this code please
    By korbitz in forum Windows Programming
    Replies: 3
    Last Post: 03-05-2004, 09:11 AM
  3. I cant find what is wrong with this code
    By senegene in forum C Programming
    Replies: 1
    Last Post: 11-12-2002, 05:32 PM
  4. Anyone see what is wrong with this code?
    By Wise1 in forum C Programming
    Replies: 2
    Last Post: 02-13-2002, 01:01 PM
  5. very simple code, please check to see whats wrong
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-10-2001, 12:51 AM

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