![]() |
|
#41
|
|||
|
|||
Switch doesn't work?No errors at all on compile now, but my "switch within a switch" just won't "work"
I can select "New Shape" by pressing one, and then return; then it displays nothing and lets me tap in return twice and then closes. Here's the switch: CPP / C++ / C Code:
|
|||
|
#42
|
|||
|
|||
Re: Linked Lists advice requestQuote:
You are violating basic rules of C. Look at your errors. What does "initialized" mean. (look it up) Describe crash. - An alert box informing of fatal blah blah and has to shut down the program and you get a command line? - cursor sits there and your input doesn't do anything. - If the former your probably trying to store data outside of your programs' allocated user space. - If the latter it's probably an endless loop. look for it... |
|
#43
|
|||
|
|||
Re: Linked Lists advice requestOk, here are some debugging tips that will greatly help you.
In each case add a printf telling you where the program entered and what the values are, try to get in each menu, see which work which don't which values you have and what they are compared to, rubbish values will indicate out of bound variables (if you're lucky). If you want to debug your menu easily just compile the menu separately removing all the stuff in between and see how it works, once you get the prototype working just adjust your program. This is by far simpler than what you've been throwing around before, try to understand the way switches work. Max |
|
#44
|
|||
|
|||
Re: Linked Lists advice requestNothing yet eh?.... consider this-
CPP / C++ / C Code:
Then and ONLY then... move to the next. Do not pass go... ++Howard; |
|
#45
|
|||
|
|||
Re: Linked Lists advice requestThe crash, was definitely something to the outtextxy part of the code, as it didn't happen when I commented all the outtextxy stuff out.
What happened was: 1. the prog executed and displayed the menu as normal 2. i entered "1" and pressed "return" 3. The cursor moved below the menu and changed - I think it resembled the way text changes in appearance when you used outtextxy (looking a bit like the text display on an old Commodore 64), 4. I pressed "return" twice, the "press any key" printf was displayed, (4.a. I pressed "return", a "windows error report" came up... but doesn't happen now) 5. the prog closed. I wonder if the outtextxy thing needs the screen clearing before it can display? I tried inserting a cleardevice to remove the menu after the selection, but it had no effect. Thanks again Howard - I've learnt more about C these last few days than I have in the last few months! I think the switch needs rearranging, thus: select_shape_switch -> draw shape then switch_between: move_shape_switch (use 4 cursors); size_shape_switch; rotate_shape_switch; colour_select_switch (all use 2 cursors). ...of course if that's prone to problems, then I suppose having a sequential list of switches is probably fine. (the problem is not that I'm not capable of looking stuff up and working logically and sequentially; it's just that I get very little time to play with this (wife & kid) - which makes me rush things because I can't rely on having enough time to carry on with summat... plus I'm on a different timezone to most of you... sorry for complicationalerising things) |
|
#46
|
|||
|
|||
Re: Linked Lists advice requestThen wouldn't it make sense to make it Quality time with either?
Playing around with simple modules and realizing what they demonstrate can actually reduce time and hair-tear in the long run by increasing your intuition of what might cause a particular problem even before you write it into the code or after you are getting errors. You might then go spend time with your family with a smile instead of a frown. ...and after all, isn't that what it's all about? smiling? I urge you to try playing with the simple nested switch I posted and observe behavior. Inserting the below should give you an idea of what might be causing the alert-box-failure. Help us help you , , run the code Luke... CPP / C++ / C Code:
Anyhow , that's basically how you get a segfault , to my knowledge. Any Others? Take your time and have fun... Last edited by Howard_L : 18-May-2007 at 09:55.
|
|
#47
|
|||
|
|||
Re: Linked Lists advice requestAlright Yoda, "code the run I shall"
Actually, this morning when I posted that, the rib was ullulating at me from the kitchen whilst his majesty (the toddler) was bawling, so I'm forever getting interrupted, that's the thing - I've just done her maths homework for her to get left alone for this aft' so I can play with the code you posted, and get summat that works by next Choose-day. I was just thinking (for a change), could I put another .c file in the workspace called "test.c" to run bits of code without any digital flatulence from my computer? Quote:
I'm going to dump all that silly outtextxy stuff and just stick to a basic array and printf menu with the switches. The only other issue is my rotation matrix code implementation posted earlier - you said it was confusing? is it? does it not make sense? thanks again for your endless patience, may the farce be with you. It spat out that modification to Case 2-3 (I did put it in the right place... when I declared iptr, it when into an eternal build loop, and I had to do ctrl+alt+del) CPP / C++ / C Code:
|
|
#48
|
|||
|
|||
Re: Linked Lists advice requestQuote:
You included that snippet years ago along with a bunch of other stuff that didn't work. I don't know what the best way to manipulate a shape would be. Haven't thought about it that much. I'm green at this too and just TRYING to follow along with what you're trying to do. That's why it would be nice if you could keep it a simple as possible and focus on one thing instead of cramming a bunch of stuff in there and wondering why it doesn't work... I would suggest a logical approach like this (again): Phase 1: - make one object like a triangle because it only has three points. . . Don't worry about user definitions at this point, define it in the program. . . make it compile and run until your satisfied with it. Phase 2: - try a simple manipulation like clear the window and redraw in a different location. . . I guess use a getch() to stop it at first position or #include <time.h> sleep() Phase 3: - try successive moves , like start it on the left and move it across the screen. - Keep your code as simple as possible and orderly. - Post with problems your having with accomplishing those "simple" tasks including the full code of as far as you can get , noting where how far you had gotten succesfully and then what you tried to add that caused problems. - After you've sent us a succesfull compile of that we can talk about rotation. . . we will all be on the same page. - Also, don't try to "plug" other people code in. . . Instead "realize" how they work and write your own. Now, go to it man, don't even think about asking about phase 4 until this is done! |
|
#49
|
|||
|
|||
Re: Linked Lists advice requestQuote:
...for this code CPP / C++ / C Code:
tsk |
|
#50
|
|||
|
|||
Re: "bunches" of "stuff"the now palaeolithic rotation thing I was on about is on page 4 (#36) - I won't repost it, to keep you calm.
I am focussing on the switches now... the extra bit in the case won't work, so I s'pose I'll just leave it, and start using it as a guide to rebuild my own switches. |
Recent GIDBlog
Problems with the Navy (Chiefs) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| triangle (polygon), drawing, sizing, and rotation programme using linked lists... | promsan | C Programming Language | 12 | 14-May-2007 15:03 |
| Doubly linked lists in C++ | sweeeeeeetlipss | C++ Forum | 1 | 24-Oct-2006 00:27 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 14:12 |
| help on linked lists any1????? | nick4 | C Programming Language | 1 | 17-May-2004 10:32 |
| linked lists, newbie needs help | moltarim | C Programming Language | 4 | 06-May-2004 12:32 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The