C .. help needed!

Pagina 1/2
| 2

Door Moniz

Champion (340)

afbeelding van Moniz

17-10-2010, 01:10

Hello All,

After some reading I found out that learning how to program in Basic is as hard to learn as C, so I thought I might as well skip to C since I can do much more with that (especially when I want to use it later on another system)

I've downloaded the stuff i needed: a text editor (TED) and a C-compiler (Ascii c-compiler v1.20) + some extra needed files
I also got the famous "c programming languange" book by Brian W. Kernighan and Dennis M.Ritchie.
And offcourse the first thing I tried is: (I'm really feeling like a nOOb right now Tongue) "Hello, world!"

I made a .c file containing the text:

#include <stdio.h>

main()
{
printf("Hello, world\n");
}

and saved the file as test.c
Then I tried to compile the file by typing c test.c
Everything goes well untill I get the message "illegal .TCO file at 0.1"

what am I doing wrong?
Am I missing something? a file or whatever?

thanks!

Aangemeld of registreer om reacties te plaatsen

Van hap

Paragon (2017)

afbeelding van hap

17-10-2010, 01:25

What does the book say about the main function?
hint: usage is not simply main() Tongue

Van Moniz

Champion (340)

afbeelding van Moniz

17-10-2010, 02:19

What does the book say about the main function?
hint: usage is not simply main() Tongue

it says:
" .. A function contains statements that specify the computing operations to be done, and variables store values used during computation. C funtions are like the functions in fortran or the procedures and functions of Pascal. Our example is a function called "Main". Normally you are at liberty to give functions whatever name you like, but "Main" is special - your program begins executing at the beginning of Main. This means every program must have a main somewhere.
main will usually call other functions to perform this job, some that you wrote, and others from libraries that are provided for you."

Van Moniz

Champion (340)

afbeelding van Moniz

17-10-2010, 02:28

later on it says (as more detailed info about "main"
"define a function called main that received no argument values statement of main are enclosed in braces, main calls library function pintf to print this sequence of caracters. \n reprecents the newline character"

Van hap

Paragon (2017)

afbeelding van hap

17-10-2010, 03:42

ah, I forgot that K&R C is a bit different. Try changing main() to void main(void), or int main(void) with a return 0; after the printf line.

Van AuroraMSX

Paragon (1901)

afbeelding van AuroraMSX

17-10-2010, 14:27

ah, I forgot that K&R C is a bit different. Try changing main() to void main(void),
That's ANSI, not K&R. K&R would be

#include <stdio.h>

int main(argc, argv)
    int argc;
    char *argv[];
{
    printf("Hello MSX-world!\n");
    return 0;
}

(Unless my K&R C is rusty ;-))

Van Moniz

Champion (340)

afbeelding van Moniz

17-10-2010, 19:27

Thanks for the help guys, but it seems that my original c file was just fine, there was something wrong with the compiler batch file (some files were missing).
Even after using you advise I still got the same error message, but thanks anyway!

Now that I know the compiler is working properly it's time to try some new stuff.
I hope I can count on your help again next time I need it! (I'll use this topic for it)

LOL!

Van larsthe18th

Master (158)

afbeelding van larsthe18th

17-10-2010, 23:59

Maybe the SDCC cross-compiler is what you need

click HERE for instructions and examples

Van Roland007

Expert (80)

afbeelding van Roland007

10-01-2015, 15:09

@Montz, I am running in to the same problem, with bootdisks that are supposed to work from the start. Which files are missing? All files mentioned in the bat file exist and can be found. The environment is also set correct

The c.bat file has these lines
cf %2 %1
fpc %1 lib
cg -k %3 %1 <- this line generates the error
m80 =%1/z
del %1.mac
l80 ck,%1,clib/s,crun/s,cend,%1/n/y/eCrazymain

If you can help me, thanks!

Van Manuel

Ascended (15371)

afbeelding van Manuel

10-01-2015, 15:30

Van Roland007

Expert (80)

afbeelding van Roland007

10-01-2015, 15:40

Sorry Manuel, that doesn't help
The author of that article is still setting up MSX-DOS 2 and the utilities. The part where the answer to my question should come, isn't there (yet)

Thanks for your help.

Pagina 1/2
| 2