Thread: Please help ><

  1. #1
    Registered User
    Join Date
    Jun 2013
    Posts
    3

    Please help ><



    Code:
    #include <stdio.h>
        #include <stdlib.h>
        #include<time.h>
         
        struct display{
        int month;
        double interest_rate;
        }
         
        void displays(FILE*displayR);
        if calculate();
        int enterOption(void);
        int main();
        
        {
        char userName[20];
        FILE*dislay;
        int options;
        time_t current=time(NULL);
        struct tm*t=localtime(&current);
        char date[30];
        char currTime[30];
        strftime(date,sizeof(date),"DATE: %b %d %Y",t);
        strftime(currTime,sizeof(currTime),"TIME: %H:%M:%S",t);
         
        printf("**************************\n\n"
        "//logo\t\t\t\tWelcome to MSYBank\n\n"
        "\t\t\t\t\t\t%s\n%s\n\n\n""**************************",date,currTime);
         
        printf("Hi, what is your name? ");
        scanf("%[ A-Z a-z ]s \n",&userName);
        system("cls");
         
        printf("Welcome to MSYBank, %s !\n",userName);
        printf("Please select your option: \n");
         
        ifis(display=fopen("display.txt","w"))==NULL)
                    {
                    printf("File could not be opened.\n");
                    }
                    else
                    {
                                while((options=enterOptions())!=3)
                                {
                                            switch(options)
                                            {
                                                        case 1:
                                                                    display();
                                                                    break;
                                                        case 2:
                                                                    calculate();
                                                                    break;
                                                        case 3:
                                                                    system("cls");
                                                                    print("TQ for visiting. have a nice day!^^");
                                                        default:
                                                                    printf("Incorrect options\n");
                                                                    break;
                                            }
                                }
         
                                ifclose(display);
                    }
                    return 0;
        )
         
        void displays(FILE*displayR)
        {
        FILE*displayW;
         
        struc display={Tenor(months),interestRate};
         
                    if((displayW=fopen("displays.txt","w"))==NULL)
                    {
                    printf("File could not be opened.\n");
                    }
                    else
                    {
                    rewind(displayR);
                    fprintf(displayW,"%-6d%-16lf\n","Tenor","interestRate");
         
                                while(!feof(displayR))
                                {
                                            fread(&client, sizeof(struct diplays),1,displayR);
                   
                                            if(display!=0)
                                            {
                                                        fprintf(displayW,"%-6d%-16lf\n",Tenor,interestRate);
                                            }
                                }
                               
                                fclose(displayW);
                    }
        }
         
        if calculate()
        {
        double deposit;
        int month;
         
        if (month ==1&&deposit>=5000)
        {
        printf calculate();
        }
        elseif(month>=2&&month<=60&&deposit>500)
        {
        printf calculate();
        }
        elseif
        {
        printf("invalid input!! Please enter again.");
        }
        }
         
        int enterOption(void);
        {
        menuOptions;
        printf("Here are your options\n\n"
                                "\tOptions\t\tFunction\n"
                                "\t1\t\tDisplay Interest Rate\n"
                                "\t2\t\tCalculate Interest Earn\n"
                                "\t3\t\tExit\n\n"
                                "Please select your option.\n");
         
        scanf("%d",menuOption);
        return menuOptions;
        }


  2. #2
    Registered User
    Join Date
    Jun 2013
    Posts
    3
    How to fix this errors ><
    Errors:-
    ♦Two or more data types in declaration specifiers
    ♦Expected identifiers or '(' before 'if'
    ♦Expected identifiers or '(' before '{' token

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    First off, error messages come with line numbers.
    Looking in the immediate vicinity of those line numbers and carefully read the code usually helps.

    Also, read this
    A development process

    Actually, I have trouble believing you even wrote this code at all. The real author (the one who knows about things like how to use strftime properly, and scan sets in scanf) would have NO trouble at all fixing these errors.

    No, it looks to me like it's a deliberately broken program assigned by your tutor to exercise your skill in interpreting compiler error messages.

    Also posted here
    Please check : ) - C++ Forum
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Dec 2012
    Posts
    307
    had a post, but page didnt load when i clicked post.....

    in just the first 73 lines, there is over 100 errors, from your use of "void display" to "int main"

    i can only imagine the errors from lines 74 - 127, and i dont have time to go through all of them, start fixing the obvious ones yourself!

  5. #5
    Registered User
    Join Date
    Jun 2013
    Posts
    3
    No -_- I wrote half of it, and the other half was written by my friend(yes, the strftime wasn`t written by me- was my friend, and yeah, Idk so much about c++ , only know basic ones, my friend isn`t around at the moment). And the one posted in C++ forum is me. Just thought its better to ask in other forums as well to see if I can get help. It`s up to you if you want to help. Thanks.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Stick with this one forum - you'll find none better. Most of the regulars here also read other programming forums, and find parallel posts for help to be off-putting, since it can waste a lot of their time.

    So they ignore them.

    When you post errors, copy and paste them, so the line #'s are included.

    First three items to fix:

    1)
    Code:
    if calculate();
    "if" is a key word in C, not a datatype, so you can't have it in a function return type.

    Available types are:
    Code:
    void
    char
    int
    float
    double
    struct
    union
    etc.
    or a pointer to any of the above

    But never "if", so change that

    Code:
    2) int main();
    When you start a function, you put a curly brace
    Code:
    {
    so the opening is toward the right - an "opening" brace.

    And when you end a function, you put in a closing curly brace
    Code:
    }
    as the very last character.

    So remove the ";" at the end of the line above. That is surely one of those compiler errors - and probably several of them will disappear once these three errors are fixed.

    3) if calculate, is also a function, and it also has to have the "if" deleted, and replace with either a void, or a variable, or a valid pointer.

    Fix those three things, and re-compile the program. Try to understand what the errors mean, in the code. Post up the errors that you can't figure out - with the line numbers, just as they appear.
    Last edited by Adak; 06-30-2013 at 02:52 AM.

Popular pages Recent additions subscribe to a feed

Tags for this Thread