![]() |
|
#1
|
|||
|
|||
Return type of main is not intHello!
I have to resolve a problem for a test and i've stumbled upon an error. The compiler gives me "return type of main is not int", "no newline at end of file" and syntax error at end of input. The text of the problem goes like this : "Create a function which verifies if there is a path from a node V to a node W inside an oriented graph." I've done some code... here it is... please someone tell me where i'm doing wrong, and if i am please give me a solution The compiler i've used is Codeblocks... CPP / C++ / C Code:
Last edited by raduq : 26-May-2009 at 01:48.
Reason: Please insert your C code between [cpp] & [/cpp] tags
|
|||
|
#2
|
|||
|
|||
Re: Return type of main is not intI've also tried another time... rewriting the entire code, thinking i might have missed something...
Here's the second version... but it still won't work... CPP / C++ / C Code:
Last edited by admin : 26-May-2009 at 05:29.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
|
#3
|
|||
|
|||
Re: Return type of main is not intQuote:
CPP / C++ / C Code:
Quote:
So: With the file open in your text editor, go to the point after the last character on the last line. Press 'Enter' to make sure that the last line is terminated by a newline. .The editor that I use will put a newline at the end of the file whether you enter it or not. Apparently yours does not. With my compiler (GNU gcc) both of these are warnings, not errors, but I recommend that you "fix" all of your program to eliminate warnings like this. It turns out that some warnings may be highly significant, and eliminating unnecessary warnings makes for less confusion and will decrease the likelihood of your overlooking something important in the compiler messages. Also I note that your function parcurgare_nod() has four left braces '{' but three right braces '}' Here is what it looks like when I format it with indentation that shows the structure: CPP / C++ / C Code:
Regards, Dave |
|
#4
|
|||
|
|||
Re: Return type of main is not intQuote:
The following statement should have given a warning about comparing a ponter to an int: CPP / C++ / C Code:
I think you should probably change the declaration of v to CPP / C++ / C Code:
Dave |
|
#5
|
|||
|
|||
Re: Return type of main is not intyeah, i mended those errors eventually, but the program still won't work... i've ended up with a final version of it... here it is...
CPP / C++ / C Code:
I repeat that the program has to be composed out of a function that verifies if there is a path between two nodes of an directed graph. Last edited by admin : 27-May-2009 at 00:03.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
|
#6
|
|||
|
|||
Re: Return type of main is not intQuote:
What doesn't work? Does it say that a path exists when you have entered a matrix for which no path exists? Does it fail to find a path for a matrix for which there is a path? What? In other words: 1. Show us the input that you gave the program. 2. Tell us exactly what happened. (Show the output.) 3. Tell us what you expected to happen. 4. Tell us exactly what you don't understand about the difference between 2 and 3. Regards, Dave |
|
#7
|
|||
|
|||
Re: Return type of main is not intI found where my mistake was... i had to change the "q" variable from global to local, in the function...
The input was : 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 Starting node: 1 Final node: 3 And there was no other output...coresponding to there being no path between the nodes I expected the function to verify each line of the matrix and where it found a 1(representing the nodes that are connected - by intersection of line and column in the matrix),to recall the function starting from that node. For example: On my first line: 0 1 0 1 ... it found the first one then i would have expected to recall the function with the nodes 2 and the final one ( parcurgere_nod(2,final_node) - and go to the second line of the matrix and search for another 1 in the line then call the function for that node with which it is connected and so on ), then go to the other 1 in the first line of the matrix which coresponds to the 4th node and call the function for node 4 and the final node( parcurgere_nod(4,final_node) - and if it found another 1 in the fourth line of the matrix it would go to the node with which is connected and so on until... hopefully it would find a path to the final node. I expected the function to call itself over and over until the node that it would have called at one time would be the same with the final node...so, proving that there is a path between the initial node and the final node. In my example i expected it to go like this... i will put an X where i expected the function to be. On first call... it would check the first line and find the first 1, which is replaced by the X. 0 X 0 1 0 0 0 0 0 0 0 0 0 0 1 0 Then the program would go to the next 1 of the first line 0 1 0 X 0 0 0 0 0 0 0 0 0 0 1 0 and for the places where it found the 1, replaced by X's it would call the function for that node. At the first 1 in the first line, the function would check the second line of the matrix for ones...and fine none... At the second 1 in the first line, the function would check the fourth line of the matrix for ones... and find one 1, which coresponds to the third node, and thus going to the third line... where upon calling the function, the "if" condition would be true and the message would appear. I hope I was clear enough what I expected the program to run like... |
|
#8
|
|||
|
|||
Re: Return type of main is not intQuote:
Quote:
However... If you, yourself, have found and fixed the problem, that's probably better anyhow. Regards, Dave |
Recent GIDBlog
Problems with the Navy (Enlisted) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Apache Web Server newbie problem | niss3 | Apache Web Server Forum | 1 | 13-Apr-2009 18:38 |
| Torrents Download Problem | chandeep | Computer Software Forum - Linux | 7 | 09-Oct-2006 22:37 |
| Runtime Problem involving "printf" in C Program | supamakia | C Programming Language | 2 | 09-Oct-2005 10:09 |
| a significant problem after installing Xp | mohammad | Computer Software Forum - Windows | 10 | 09-Aug-2005 07:03 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The