|
-
May 6th, 2011, 02:58 PM
#1
[RESOLVED] need help please
Last edited by sadam; May 8th, 2011 at 12:18 PM.
-
May 6th, 2011, 07:40 PM
#2
Re: need help please
In ReadFile you should be reading from a file not from the keyboard. Surely those scanf's should be fscanf's. Also drop the ncircles parameter completely as that variable is global as are s and t which can also be dropped.
Get Microsoft Visual C++ Express here or CodeBlocks here.
Get STLFilt here to radically improve error messages when using the STL.
Get these two can't live without C++ libraries, BOOST here and Loki here.
Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
Always use [code] code tags [/code] to make code legible and preserve indentation.
Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.
-
May 6th, 2011, 07:45 PM
#3
Re: need help please
Last edited by sadam; May 8th, 2011 at 12:17 PM.
-
May 6th, 2011, 07:53 PM
#4
Re: need help please
the variables you pass into the function are all GLOBAL. that means they can be accessed from everywhere. The only parameter that function needs is the filename. fscanf is slightly different to scanf. it requires a FILE* too. scanf reads only from the keyboard assuming stdin hasn't been redirected.
At the moment, you open a file for reading, try to get input from the keyboard, then close the file.
int fscanf ( FILE * stream, const char * format, ... );
thats the prototype for fscanf. See the first parameter is the file pointer which is why you got that error.
scanf is equivalent to fscanf( stdin, .......... ) which is why it never needs that parameter. its hardwired.
Get Microsoft Visual C++ Express here or CodeBlocks here.
Get STLFilt here to radically improve error messages when using the STL.
Get these two can't live without C++ libraries, BOOST here and Loki here.
Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
Always use [code] code tags [/code] to make code legible and preserve indentation.
Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.
-
May 6th, 2011, 07:55 PM
#5
Re: need help please
Last edited by sadam; May 8th, 2011 at 12:17 PM.
-
May 6th, 2011, 07:59 PM
#6
Re: need help please
For starters change it to
Code:
void ReadFile( const char* filename )
change the call to ReadFile in main to only pass the filename.
change the scanf's to fscanf's with the FILE* as the first parameter.
Get Microsoft Visual C++ Express here or CodeBlocks here.
Get STLFilt here to radically improve error messages when using the STL.
Get these two can't live without C++ libraries, BOOST here and Loki here.
Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
Always use [code] code tags [/code] to make code legible and preserve indentation.
Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.
-
May 6th, 2011, 08:03 PM
#7
Re: need help please
Last edited by sadam; May 8th, 2011 at 12:17 PM.
-
May 6th, 2011, 08:10 PM
#8
Re: need help please
Give up programming its not for you!
Code:
FILE *file;
if (( file = fopen( filename, "r" )) == NULL )
Ever going to do anything in particular with that open file pointed to by the FILE* called file??
Get Microsoft Visual C++ Express here or CodeBlocks here.
Get STLFilt here to radically improve error messages when using the STL.
Get these two can't live without C++ libraries, BOOST here and Loki here.
Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
Always use [code] code tags [/code] to make code legible and preserve indentation.
Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.
-
May 6th, 2011, 08:13 PM
#9
Re: need help please
Last edited by sadam; May 8th, 2011 at 12:17 PM.
-
May 6th, 2011, 08:15 PM
#10
Re: need help please
btw you will also need to drop the asterix here
i<*ncircles
as ncircles is a global int, not an int* so dereferencing it is completely wrong.
Get Microsoft Visual C++ Express here or CodeBlocks here.
Get STLFilt here to radically improve error messages when using the STL.
Get these two can't live without C++ libraries, BOOST here and Loki here.
Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
Always use [code] code tags [/code] to make code legible and preserve indentation.
Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.
-
May 6th, 2011, 08:17 PM
#11
Re: need help please
fscanf( file, .............. )
how hard can it be. you open the file but never read from it. You have to tell the fscanf where to read from.
Get Microsoft Visual C++ Express here or CodeBlocks here.
Get STLFilt here to radically improve error messages when using the STL.
Get these two can't live without C++ libraries, BOOST here and Loki here.
Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
Always use [code] code tags [/code] to make code legible and preserve indentation.
Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.
-
May 6th, 2011, 08:29 PM
#12
Re: need help please
Last edited by sadam; May 8th, 2011 at 12:16 PM.
-
May 6th, 2011, 08:34 PM
#13
Re: need help please
Use your debugger and find out. Learning to debug your code is part of learning to program. work out on pen and paper what values you expect in variables and watch to see whats actually happening as you step through your code. When you see something unexpected, work out what went wrong and fix it.
Get Microsoft Visual C++ Express here or CodeBlocks here.
Get STLFilt here to radically improve error messages when using the STL.
Get these two can't live without C++ libraries, BOOST here and Loki here.
Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
Always use [code] code tags [/code] to make code legible and preserve indentation.
Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.
-
May 6th, 2011, 08:36 PM
#14
Re: need help please
Last edited by sadam; May 8th, 2011 at 12:16 PM.
-
May 7th, 2011, 11:43 AM
#15
Re: need help please
 Originally Posted by sadam
that means that my program is wrong? can you help me fix it because the deadline is nearby?
You wrote the code, therefore you must have known what every variable, function, line of code does.
Therefore, what is stopping you from debugging your own code? You wrote it, right? So why can't you debug something you wrote? As was stated, learning to debug your programs is part of learning how to program. So asking us to do the work you're supposed to have done is almost and maybe, just as bad as one of us writing the code for you.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; May 7th, 2011 at 11:46 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|