-
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(¤t);
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;
}
-
How to fix this errors ><
Errors:-
♦Two or more data types in declaration specifiers
♦Expected identifiers or '(' before 'if'
♦Expected identifiers or '(' before '{' token
-
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
http://cboard.cprogramming.com/c-pro...t-process.html
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
-
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!
-
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.
-
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)
"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
When you start a function, you put a curly brace so the opening is toward the right - an "opening" brace.
And when you end a function, you put in a closing curly brace 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.