![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | ||
|
Newbie
Join Date: Aug 2005
Posts: 12
Rep Power: 0
![]() |
Having trouble compiling a SAW routine
I am trying to a sample self-avoiding random walk routine, but my compiler doesn't compile and it gives me error messages due to this line.
Quote:
error 142 - Void type not permitted here error 192 - An object of type 'void' cannot be assigned to an object of int Here's the program: Quote:
|
||
|
|
|
|
|
#2 | |
|
Professional Programmer
|
Try replacing with this?
int ipos[4] = '\0'; I'm only guessing you're trying to null the position by having "int ipos[4] = {};", and the above code would be the correct way. Or if you mean to null the entire array.. int ipos[4]; for (int i = 0; i < 4; i++) ipos[i]='\0';
__________________
▄▄▄▄ Quote:
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it. Download Code::Blocks now! ▄▄▄▄ |
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Aug 2005
Posts: 12
Rep Power: 0
![]() |
It compiles now, but I cannot get the program to work. It says it's a run time error.
Here's a link of what the sample output should look like. http://hepwww.ph.qmul.ac.uk/sim/sarw...file=sarw.html It's the very last output in the link. |
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
You need to read a thread on how to post a question. Your first post was excellent, but your second one gives no information to work with. Information is key, both in getting answers and in debugging. A sample of the proper output is essentially worthless, since your program is running off into the weeds and barfing in its shoes. One guess is that your run-time error is a memory violation. There's a good chance that you are violating the dimensions of an array somewhere. You could also be trying to modify memory that isn't your own by abusing a pointer. Collect all the information your system gives you regarding the error. Shoot, you don't even mention your platform, OS, and compiler. If you have a debugger, step through the program or set breakpoints at various places. The latter method allows you to do a binary search to zero in on the offending statements, if you play your cards right.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#5 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 915
Rep Power: 4
![]() |
Worked for me under VC2005
Final ouput: Nsteps: 50 Rsquared: 200 Weight: 0.0438957 As DaWei says, you need to give more information. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|