Actually i did try over and over, but gone nothing ! It ws giving me a lot of errors
Printable View
You are aware that strtok() can return NULL, right? So this code:
May not always succeed 100% of the time.Code:ptr=strtok(sentence,"\n");
strcpy(detail.complete,ptr);
Deletification!
Yeah please do email it to me. I am never one to turn down an email from a distressed blond.
I will read it momentarily. I need to go get some caffein real quick.
Ok... looking at the code, there is a lot I can say about a lot of things.
1. Don't call main() ever. I mean generally speaking, unless you are in some way in charge of how the program is entered, you should never be calling main recursively for any reason.
2. You are checking to see if the temp file was created twice. Its not a huge deal, but redundant. It won't just disappear at random between the time you opened it and the time you are about to use it, and to be frank; even if some unlikely IO failure took place, your program would likely not even be aware that it owns an invalid handle.
3. The above code, although amusing seems to do nothing than validate user input every single time. Which is a good thing! Don't get me wrong, however it always prompts the user as to when they do input something correctly (with a rather sarcastic quip, so you get some points for that). It is annoying for the end user.
4. This checks an answer's correctness AFTER the entire file has been processed: ergo, you never technically know which questions were answered right, and which ones weren't.
5. You shouldn't be using strcpy(myvar, NULL). Therefore, you should always check the ptr variable to make sure it isn't NULL prior to passing it into strcpy.
Thank for all the pointers Matt, Oh by the way if ssdue does get on here, he should know im giving him credit on the validation part. So dnt start getting ........ed off ssdue. About calling main, how should i rather call it instead. Rather that doin what i had
I recommend having choice() return some sort of value. Then use that value to tell the function calling choice() whether or not to loop. In other words, you could have all of the contents of main() controlled by a giant while loop that depends on the value returned by choice().