The amount of code that I posted was a tiny piece of the assignment.
Is there any way else to express the problem without posting the code?
About my problem now, probably the if else isn't a good solution to my problem.
Should I give it one more try or should I look for sth else?...
User Profile
Collapse
-
if else brackets problem
...Code:for (i=0; i<8; i++) { if(score[i]==-2) { if(i<3) { for (j=0; j<3; j++) { if (P[i][j]=='\0') { P[i][j]='O'; j=3; } } else if (i<3 && i<6)[B]I get a message here: "expected[/] -
Finally there is a more simple way to do this without pointers.
But just to enrich my knowledge I would like to find how to do it both ways.Leave a comment:
-
Please note that I wasn't the one that "Pleased for help" but Xrysa.
Thank you for pointing it out for me. I did try to read about pointers and arrays before post this code but I couldn't understand much, about the particular assignment.
Can I find the answer to my question in the article "Arrays Revealed"?...Leave a comment:
-
Sorry, I post this code late after midnight and I did look for it but I didn't remember which symbol to click. Now I know!!!...Leave a comment:
-
functions arrays and pointers problem
I want to print the results of the best schedule array (which is shorted in a specific way in the find_best_scedu le function) through the main program. Actually I should print the results by using a second function named print_best_sche dule, but this seems too complicated and I prefer to do one step at a time.
The problem is that I don't know how to print the array through the pointer "ptr".
Here is the code...Last edited by Banfa; Mar 5 '08, 09:22 PM. Reason: Code removed at users request, conformance to posting guidelines -
Yes, but after compilation, they don't return any results to the screen (propably because there are no printf). And at least for me who just started reading about C is difficult to place a printf on examples with pointers and arrays, etc.
...or am I doing sthg wrong and I don't get results??????...Leave a comment:
-
Finally...I made it!!!
I don't know what went wrong at the first time and I got those strange results.
Thanks guys (or girls). You were right about your conclusions.Leave a comment:
-
I've got your point. And it seems right.
But when I write it this way
if (best_time_done[i]==-1)
if ((table[k][1]<min) && (best_time_done[k]==-1))
I get crazy results:
best time done:
0 0 4007064 16 4007072 9264 3998072
best time
96 3997696 .......etc...Leave a comment:
-
Propably, I didn't explain it good enough.
The "best_time_ done[]" is an array with all the values set to -1.
Each value of this array represents a value from the array "best_time[]".
For example.
"best_time_ done[1]=-1" means that the first value of the array "best_time[]" isn't sorted
"best_time_ done[2]=0" means that the second value of the array "best_time[]"...Leave a comment:
-
wrong estimations and confusion with arrays
I must sort the below values of table[][3] in a specific way.
Everytime that I possition a sorted value to the best_time array, I marked it as a "job done" by giving the value 0 to the table best_time_done[7].
Though I mark the "best_time_ done[2]=0" the program keeps estimating it as a value of -1 and not a 0.
I debugged it and I saw that it is best_time_done[2]=0. But when it reaches the
if (best_time_done[2]=-1)...Last edited by sicarie; Feb 27 '08, 06:40 PM. Reason: Code tags are [code=c] and after your code [/code]. Please use them. They want to be used. They like to be used. -
I'm sorry if I made you think that I'm looking for someone to solve my assignments, I didn't mean it.
I'm a married working woman with a child (and mature enough to respect the "laws" of universities) and I really really luck of free time.
I do my best and I want to learn as much as I can, though my whole schedual is too hard (to keep up with), I don't want to give up. I have worked to the bone with this one and I couldn't...Leave a comment:
-
Hi again and thank you for your time!
First of all I would like to mention that I am the newbiest newbie in C programming, (I start reading about C, just 2 weeks ago) though I'm trying hard to figure everything out. Now, about my problem...
I did try to do that, but it didn't work out (due to my mistaken code...of course)...there fore I wrote the above code.
Could I have a hint on how to do that?...Leave a comment:
-
You are right about your thoughts!!!
Actually, this is the way I did it for the first time.
But, even if I tried it, your way (which is the right one) I still get wrong results.
What it happens, is that the result should be result=2
And that is what I get as I run the program, but unfortunatelly, it doesn't stop there.
It goes on to:
for (i=0; i<8; i++)
{
if ((move_main==9)...Leave a comment:
-
problem with logical operators
Hallo everyone,
I have written the below code but it doesn't work right.
The problem is that when I run it, and
the score_main array has a value of -3 or 3 and at the same time
the move_main is 9, I get as a "result" the number 3, which is wrong
according to this:
[CODE=c] for (i=0; i<8; i++)
{
if ((move_main==9) && ((scor... -
Very good article!
If you could write some examples that we could copy and paste them to a compiler, just to see the result, it would be nice!Leave a comment:
-
My congratulations "weaknessforcat s".
Functions are troubling me too and you made everything, more than crystal clear!Leave a comment:
-
problem in functions
Hi, I'm a newbie and I have to make the following assignment.
We are asked to use this function
void get_input(char P[3][3], int *line, int *column);
It is a part of a tic-tac-toe game and we have to use the above function
in order to ask the player to give the coordinates of the cell. In that cell will be placed the letter "X".
I have many problems.
I have written the code and if I use...
No activity results to display
Show More
Leave a comment: