Hi...me again same program different problem.

This is a discussion on Hi...me again same program different problem. within the C Programming forums, part of the General Programming Boards category; I'm writing a program that will take three test scores of a student whose name has been inputted by the ...

  1. #1
    Registered User arti's Avatar
    Join Date
    May 2010
    Posts
    108

    Hi...me again same program different problem.

    I'm writing a program that will take three test scores of a student whose name has been inputted by the user and that number will be divided by 3, finding the average.

    My problem isn't working, well when I gcc my proyect I get a lot of warnings. May someone revise my code please. Thank you so much I appreciate your help.


    #include<stdio.h>
    #include<string.h>

    #define addr(var) &var
    #define REPORTHEADING1 "Student T1 T2 T3 Avg\n"
    #define REPORTHEADING2 "======= == == == ===\n"
    #define REPORTFORMAT "%-10s%3d%7d%7d%8.2f\n"
    #define BLANK2LINES "\n\n"

    void InputStudentInfo(char *fn, char *ln, char fullName);

    Code:
    int main (void)
    {
     char lastname[15+1], 
          firstname[10+1];
     char combinedName[27+1];
     int t1,t2, t3;
     float avg;
     
     printf(BLANK2LINES);
     InputStudentInfo(lastname, firstname, combinedName);
    
     printf("Enter the student's three(3) test scores seperate with space ");
     scanf("%d%d%d", addr(t1),addr(t2),addr(t3));
     avg=(t1+t2+t3)/3.0;
     printf(BLANK2LINES);
     printf(REPORTHEADING1), printf(REPORTHEADING2);
     printf(REPORTFORMAT, combinedName, t1, t1, t3, avg);
     fflush(stdin);
     return 0;
    }
    void InputStudentInfor(char *fn, char *ln, char fullName)
    {
     char comma=',';
     printf("Enter the student's first name");
     scanf("%s", fn);
     printf("Enter the student's last name");
     scanf("%s", ln);
     
     strcat(fullName,comma);
     strcat(fullName, fn); 
    }
    Last edited by arti; 05-04-2010 at 01:05 AM. Reason: I reiterate I'm knew at this...C programming is hard for me.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why on earth did you make a macro to get an address? If you are getting a lot of warnings, as you put it, why don't you start fixing them? strcat expects two string arguments, not an argument and a character. (comma)


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multi Thread Program Problem
    By ZNez in forum C Programming
    Replies: 1
    Last Post: 01-03-2009, 10:10 AM
  2. Program Termination Problem
    By dacbo in forum C Programming
    Replies: 3
    Last Post: 01-23-2006, 01:34 AM
  3. Inheritance and Dynamic Memory Program Problem
    By goron350 in forum C++ Programming
    Replies: 1
    Last Post: 07-02-2005, 02:38 PM
  4. Replies: 20
    Last Post: 06-12-2005, 11:53 PM

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