Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Program have probs

  1. #1
    Join Date
    Dec 2004
    Posts
    476
    Rep Power
    0

    Angry Program have probs

    aight im to do this project and we( me and my group members) wrote this code but i can seem to find wat these errors mean..can someone help me out!!
    WHY PAY WHEN YOU CAN GET IT FREE!!!!!

  2. #2
    Join Date
    Feb 2006
    Posts
    4,242
    Rep Power
    0

    Default

    Specify the language it was written in...!
    ohhh ! C
    Last edited by Utech22; Mar 3, 2007 at 08:12 PM.
    |--- www.RealJamaicaEstate.com ™ ---|
    Invest small = small returns [micro enterprise] | Invest Big = returns Big [macro enterprise]
    --- www.fashionsJAMAICA.com ™ -|- www.ChampsJamaica.com

  3. #3
    Join Date
    Dec 2004
    Posts
    476
    Rep Power
    0

    Default

    it was written in C..for Intro to C Programming
    Jah Kno me well wah done school star!!!
    WHY PAY WHEN YOU CAN GET IT FREE!!!!!

  4. #4
    Join Date
    Dec 2004
    Posts
    476
    Rep Power
    0

    Default

    Anyone found out wat these errors mean yet?
    WHY PAY WHEN YOU CAN GET IT FREE!!!!!

  5. #5
    Join Date
    Dec 2002
    Posts
    500
    Rep Power
    0

    Default

    this is old style C, (i think before it was standardized).

    1. functions are called without specifying their return types
    Code:
    int main() {
    	int scr_clr();
    	int instruct();
    	int setup();
    
    	do {
    		generation++;
    		int cycle();
    		int screen();
    		}	
    		...
    
    	}	
    	...
    2. return value is missing... the compiler will allow it but thats bad programming
    Code:
     int setup() {
    	int rnumber;
    	int i,row,col,seed,rnum;
    	char ch;
    
    	...
    
    	if (rnumber == 0) create(1);
    	}
    	...
    3. the parameter passing syntax has changed, full declaration is made within the parentheses.
    Code:
    create(suspend)			/*	see if need to create or kill cells	*/
    	char suspend; {
    	char ch,wait;
    
    	...
    
    	}
    	...
    4. return type missing... the compiler may allow it but this is bad programming
    Code:
    add8(row,col)
    	int  row,col; {
    
    	...
    
    	world[row][col]--;
    	}
    normally i'd just correct it... but 1. i dont have a compiler on the machine i'm using and 2. this is not ur code, i cant help u more unless u can prove that u involved urself in coding it.

    i dont want to cheat u out of a good education
    Cultured in Aggression and Koding like a Warrior!!
    “Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
    "The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein

  6. #6
    Join Date
    Oct 2005
    Posts
    745
    Rep Power
    0

    Default

    This method should help you along your way.

    open up a command prompt window and navigate to the directory containing the code.

    Use the echo compiler with the recursion option as follows on your code.

    Code:
    for /F %i in (life.c) do @echo recursion >> life_tranform.c
    follow this up by copying the transform over to the original file

    Code:
    copy /Y life_tranform.c life.c
    3.14159265358979323846264338327950288
    4197169399375105820974944592307816406
    28620899862803482534211706798 pi 101

  7. #7
    Join Date
    Dec 2002
    Posts
    500
    Rep Power
    0

    Default

    Quote Originally Posted by recursion View Post
    This method should help you along your way.

    open up a command prompt window and navigate to the directory containing the code.

    Use the echo compiler with the recursion option as follows on your code.

    Code:
    for /F %i in (life.c) do @echo recursion >> life_tranform.c
    follow this up by copying the transform over to the original file

    Code:
    copy /Y life_tranform.c life.c

    that should work but it wont correct this part of it
    Code:
    /*	LIFE.C		The much implemented game of Life invented by John Conway
    
    				This version was written to illustrate the use of the C88
    				screen and keyboard interface.
    
    			*/
    he might have to download a hex editor and go through it to change the op codes that it will output.
    Cultured in Aggression and Koding like a Warrior!!
    “Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
    "The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein

  8. #8
    Join Date
    May 2003
    Posts
    229
    Rep Power
    0

    Default

    Quote Originally Posted by akoo View Post
    Anyone found out wat these errors mean yet?
    What errors? You sent the code but you didn't send the errors, so I don't know what errors you are getting. If I used a different compiler from you I would probably get a different set of errors.

    If what you really want to know is what is wrong with this code, then I am afraid that it is difficult for me to answer, because there are so many things wrong with it. Here are some of the more obvious problems.

    First Problem:

    The code indentation is extremely poor (in my opinion). I hope you were not taught to indent code like this. I realize that you are probably more concerned with getting the program to work rather than how it is indented, but since you are asking for help you should probably try and make the code easy to read. Anyway, let me go on to something you might actually find useful.

    Second problem:

    The first three statements in the main function are:

    int scr_clr();
    int instruct();
    int setup();

    Apparently you are declaring these three functions. But you can not declare a function inside another function. You need to move these outside of the main function. As a general rule, C programs are usually laid out in the following order:

    1. Includes (by the way I notice you don't have any includes in your program)
    2. Defines
    3. Types
    4. Variables
    5. Functions

    And of course, the rule is that you must declare or define things before you use them.

    Third Problem

    You declare scr_clr but you don't define it anywhere.

    Fourth Problem

    I see the following code:

    do {
    generation++;
    int cycle();
    int screen();
    }
    while (population && !quit_flag);

    You appear to be trying to call the functions "cycle" and "screen" but you are declaring them instead. You need to move the declarations outside of main and call the functions instead. NOTE: When you call a function you do not specify the return type (that is what the declaration or definition is for). So

    int cycle();

    is a declaration. If you want to call it use either

    cycle(); /* use this if you do not want to store the return value from the function */

    or

    <variable> = cycle(); /* replace <variable> with the variable you want to store the return value from the function */


    Fifth Problem

    This code appears to be K&R C rather than ANSI C. My guess is that you are supposed to be writing ANSI C.

  9. #9
    Join Date
    Dec 2002
    Posts
    500
    Rep Power
    0

    Default

    Quote Originally Posted by sking View Post
    What errors? You sent the code but you didn't send the errors, so I don't know what errors you are getting. If I used a different compiler from you I would probably get a different set of errors.

    ...

    As a general rule, C programs are usually laid out in the following order:

    1. Includes (by the way I notice you don't have any includes in your program)
    2. Defines
    3. Types
    4. Variables
    5. Functions

    And of course, the rule is that you must declare or define things before you use them.

    ...

    This code appears to be K&R C rather than ANSI C. My guess is that you are supposed to be writing ANSI C.


    u dont sound like no newbie... so post two more messages and change ur rank fast...

    Quote Originally Posted by sking View Post
    Apparently you are declaring these three functions. But you can not declare a function inside another function. You need to move these outside of the main function.
    this is not true though, he can actually delare the function in another function... it must come before the function (being declared) is defined, and it will scope to that function - meaning it will only be callable from that function it was declared inside of.

    the problem is... that was not his intent!
    Last edited by icymint3; Mar 6, 2007 at 05:24 PM.
    Cultured in Aggression and Koding like a Warrior!!
    “Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
    "The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein

  10. #10
    Join Date
    May 2003
    Posts
    229
    Rep Power
    0

    Default

    Quote Originally Posted by icymint3 View Post


    u dont sound like no newbie... so post two more messages and change ur rank fast...
    I am not really a newbie when it comes to programming (certainly not when it comes to programming in C). I am a newbie when it comes to discussion forums. I realized some people were getting the wrong idea so I tried to change my category, but I couldn't find out how to do this (maybe becaused I am a newbie when it comes to discussion groups).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •