Jump to content
  • Advertisement
Sign in to follow this  
kshoalin

help with my personal code

This topic is 3938 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#include <iostream> #include <cmath> #include <iomanip> #include <string> using namespace std; void phonenumber(); void Display(); void Heading(); void outdisplay(); int main() { int input; cout<<"Enter Full Name: "<<endl; cin>>input; cout<<input<<"Records:"<<endl; int x; cin>>x; return 0; } void phonenumber() { int number; int address; int zipcode; int city; int email; { cout<<"Enter your Phone Number: "<<endl; cin>>number; cout<<"Enter your Adress: "<<endl; cin>>address; cout<<"Enter your City/Town : "<<endl; cin>>city; cout<<"Enter your Zip Code: "<<endl; cin>>zipcode; cout<<"Enter your Email Address : "<<endl; cin>>email; { for(int i=0;i<0;i++) } } } void Display() { cout<<"Reviewing Records.............."<<endl; cout<<"PLEASE WAIT!!!!!!!!!.........." <<endl; cout<<"..PLEASE WAIT!!!!!!!!!......" <<endl; cout<<"....PLEASE WAIT!!!!!!!!!...." <<endl; cout<<"......PLEASE WAIT!!!!!!!!!.." <<endl; cout<<"........PLEASE WAIT!!!!!!!!!" <<endl; cout<<"..........PLEASE WAIT!!!!!!!" <<endl; cout<<"............PLEASE WAIT!!!!!" <<endl; cout<<"..............PLEASE WAIT!!!" <<endl; cout<<"..................PLEASE WAIT!" <<endl; cout<<"........................PLEASE WA" <<endl; cout<<"................................PL"<<endl; cout<<"To Obtain Your Records Press Enter KEY......"<<endl; } void Heading() { char Enter; { cout<<".............Record Profile................"<<endl; cin>>Enter; } } void outdisplay() { int number; int address; int city; int zipcode; int email; int input; { cout<<"The Phone Number:"<<number<<"Matches our Records to Account Holder"<<input<<endl; cout<<"Your address should be:"<<address<<city<<zipcode<<endl; cout<<"Can we still email you at this address"<<email<<"?"<<endl; } this is my error 1>------ Build started: Project: Programmin, Configuration: Debug Win32 ------ 1>Compiling... 1>Programmin.cpp 1>c:\users\ben\programming codes\programmin\programmin\programmin.cpp(42) : error C2143: syntax error : missing ';' before '}' 1>c:\users\ben\programming codes\programmin\programmin\programmin.cpp(85) : fatal error C1075: end of file found before the left brace '{' at 'c:\users\ben\programming codes\programmin\programmin\programmin.cpp(72)' was matched 1>Build log was saved at "file://c:\Users\Ben\Programming Codes\Programmin\Programmin\Debug\BuildLog.htm" 1>Programmin - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== i want this program to enter a name adress, zipcode, etc and then press any key after to continue, then my program acts like it is scanning then it should display record profile as the heading and then reply message back to the user saying i found a match.also what is a tip on how to output the input to a txt file on my harddrive how do i do that. and can i choose a name to save it as.please help me

Share this post


Link to post
Share on other sites
Advertisement
A few things:

1. It's a good idea to use the source tags when posting code on the forums, it makes it much easier to read with proper tabbing and syntax highlighting. e.g


void example(void)
{
printf("blah\n");
}



See here for usage of source tags and others. Also, make sure you've tabbed out your code properly in the first place, that really helps for finding mismatched braces.

2. The error messages spewed by the compiler gives you the line number the error is on. Find this line of your code and look at it very carefully to see if there is anything wrong. If you can't find it, sometimes it helps to look at the line above too. The actual error message given by the compiler isn't always 100% helpful, think of it more as a hint.

I'm not going to tell you what the problem with your code is. You need to figure that out for yourself.

As for output to a file, google std::fstream.

Share this post


Link to post
Share on other sites
For every opening curly brace '{', you need to have a corresponding closing brace '}'. You have 8 opening braces but only 7 closing braces. The error you are receiving is basically telling you that it is encountering the end of the file before it encounters a closing brace that it is expecting. It probably won't give you the exact line of code that the problem exists, because with a problem like this, the compiler can't determine where the curly brace is supposed to be. As the programmer, you have to supply it. So, read over the program and make sure that all of your code blocks are properly enclosed. Visual Studio often helps with this, in that whenever you type a curly brace, it will highlight it and its corresponding brace in bold, if a corresponding brace exists.

My guess is that your problem lies within the outdisplay() function.

Share this post


Link to post
Share on other sites
Proper indenting makes a huge difference in terms of code readability. Perhaps this will help
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

void phonenumber();
void Display();
void Heading();
void outdisplay();

int main()
{
int input;
cout<<"Enter Full Name: "<<endl;
cin>>input;
cout<<input<<"Records:"<<endl;
int x;
cin>>x;
return 0;
}

void phonenumber()
{
int number;
int address;
int zipcode;
int city;
int email;
{
cout<<"Enter your Phone Number: "<<endl;
cin>>number;
cout<<"Enter your Adress: "<<endl;
cin>>address;
cout<<"Enter your City/Town : "<<endl;
cin>>city;
cout<<"Enter your Zip Code: "<<endl;
cin>>zipcode;
cout<<"Enter your Email Address : "<<endl;
cin>>email;
{
for(int i=0;i<0;i++)
}
}
}

void Display()
{

cout<<"Reviewing Records.............."<<endl;
cout<<"PLEASE WAIT!!!!!!!!!.........." <<endl;
cout<<"..PLEASE WAIT!!!!!!!!!......" <<endl;
cout<<"....PLEASE WAIT!!!!!!!!!...." <<endl;
cout<<"......PLEASE WAIT!!!!!!!!!.." <<endl;
cout<<"........PLEASE WAIT!!!!!!!!!" <<endl;
cout<<"..........PLEASE WAIT!!!!!!!" <<endl;
cout<<"............PLEASE WAIT!!!!!" <<endl;
cout<<"..............PLEASE WAIT!!!" <<endl;
cout<<"..................PLEASE WAIT!" <<endl;
cout<<"........................PLEASE WA" <<endl;
cout<<"................................PL"<<endl;

cout<<"To Obtain Your Records Press Enter KEY......"<<endl;
}

void Heading()
{
char Enter;
{
cout<<".............Record Profile................"<<endl;
cin>>Enter;
}
}

void outdisplay()
{
int number;
int address;
int city;
int zipcode;
int email;
int input;
{

cout<<"The Phone Number:"<<number<<"Matches our Records to Account Holder"<<input<<endl;
cout<<"Your address should be:"<<address<<city<<zipcode<<endl;
cout<<"Can we still email you at this address"<<email<<"?"<<endl;
}




HINT: Look to make sure your { and } match up. As well, make sure your braces({ and }) are in the correct spots.

Share this post


Link to post
Share on other sites
Hello,

There is some other errors that will not be display by the complier. For example, you are using wrong data types for things. To store a phone number, address, city, and email you should use a string type. Not an integer type. It will not correctly store the information. Maybe you should even store the zip code as a string type.

Also, can I ask you use brackets inside of a function. You know you are changing the scope of things, so before you actually do that learn about the scope of things in C++.

Another thing is that you declare variables in a function and once it gets finished with the function it goes out of scope. Therefore, you can not declare variables in the phoneNumber() function and expect to access it in outDisplay() function. You have to declare it in the main and send it as a parameter for both functions, but you should send a reference to it in the phoneNumber() function so it can directly access the variables in the main() function and change it. Otherwise it sends a copy of the variables and don't change it, or maybe break it up to smaller functions which returns the values to the main function.

Also, you never call your functions from the main() function, so it will never execute when you run the program. There may be more errors in your program, but those are the ones I immediately noticed.

To answer your last question you can save it to a file. You have to look up Input/Output (shorter term is I/O) for C++.

~Carl J. Loucius

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!