Hi all! I have a phone book program here which I will admit is not of my hand, but I have modified it a little bit, but it won't work in my compiler. What should I do??? It is attached
Hi all! I have a phone book program here which I will admit is not of my hand, but I have modified it a little bit, but it won't work in my compiler. What should I do??? It is attached
Last edited by FerrariF12000; 12-09-2003 at 01:03 AM.
Code:exit();
Code:exit(0);
Did it compile before you started modifying it?
How many changes did you make before trying to compile it again?
> What should I do
Go back to your original source and make fewer changes before pressing compile.
Then you will have fewer mistakes to worry about, and more idea of where the mistakes are
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.
Please Indent the code next time when you upload,
some of the errors are
1) character variable cannot be initialized to NULL pointer
2) To find whether the char variable isn't used, the code checks whether this variableCode:s.homec = '\0'; // NULL is used only to initialize pointers s.offc = '\0'; // It needn't be '\0' it can be any character s.cellc = '\0';
corresponds to the initial value (see below).
3) Instead of using fflush(stdin) to flush buffer (which doesn't serve any purpose), use a singleCode:if(s.homec == NULL) // NULL has to be '\0' printf("\tHome Phone : %-12.0lf",s.homei);
space after '"' in scanf statement, as in the code below
Leaving a single space indicates the compiler to get a fresh input and not from the standardCode:scanf(" %s",s.fname);
input buffer.
Nope, I actually didn't modify any of the source just some of the text, yeah I would be very careful if I did modify the source. When I got the program, it never compiled with my compiler, but it did have an already compiled version, but I needed to modify it sooooo that is why I am here.Originally posted by Salem
Did it compile before you started modifying it?
How many changes did you make before trying to compile it again?
> What should I do
Go back to your original source and make fewer changes before pressing compile.
Then you will have fewer mistakes to worry about, and more idea of where the mistakes are
Thanks all, I am going to try all of those things you guys said.
Well guys I got it to run pretty well, except I cant delete the entries I put on my computer, would you check to see if it works okay on ur guy's comps??? please....
Seems OK to me (in the sense that it runs and deletes stuff).
I started off by deleting the pbook.dat
Some points
1. fp = fopen("pbook.dat", "rb++");
++ is not a mode
2. scanf(" %lf", &s.celli);
It's just %f for floats
Besides, using floats to store phone numbers sucks, you should really store them as strings.
Especially if you want to preserve any leading zeros.
Your main() is 300 lines long, use some functions man.
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.
haha! yup, that's one of the reasons I didnt take the credit for making it. To me it looks extremely old-fashioned with ancient code. Anyway I will be messing with it tomorrow so ill let u no how that goes.