Hi I’m trying to do the beginning lessons in Sam’s Teach yourself C in 21 days using LiteC in legacy mode. I could use some help. Can you tell me why things aren’t working.
So I tried lesson 1 the Hello world program.
Sam’s has it as
#include <stdio.h>
main()
{
printf("Hello, World!")
return 0;
}
If I try this I get a error about the stdio.h header, so I changed it to <litec.h>, that fixes that. But when I run it again i get “main” undecleared, but I know that would happen. So I did this-
#include <litec.h>
int WinMain()
{
printf("Hello, World!")
return 0;
}
I saw in the legacy example that int WinMain() was used. But when I run this it compiles but does nothing. So I change it to this.
#include <litec.h>
void main()
{
printf("Hello, World!")
return 0;
}
This works but also opens a DX window which I don’t need and didn’t ask for. This piece of code happens to be an example in the samples folder they have it as.
#include <litec.h>
int WinMain()
{
MessageBox(NULL,"Hello,World!","My first program",0);
}
But why didn’t they use printf? Messagebox is a good substitute but doesn't exactly do what printf does.I started looking at the headers (*.h) and found 3 entries for printf #1)<litec.h>(96) long printf(char*,…); #2)<stdio.h>(94) int _cdecl prinf(const char*,…); #3)<stdio.h>(243) API(printf,msvcrt)…… So I got to wounding why printf only seems to work with void main(), It’s because it’s in the litec.h as clib function internally defined in the compiler. So I’m thinking there is a step I’m missing to use it in legacy mode.. Can anyone tell me what I need to do? I ran into another function “scanf” that’s in the stdio.h like printf but returns undeclared error in the compiler. What do I need to do to use the stdio.h functions? These function must be avallible otherwise why would some one write a header including them?
EDIT* Anyone? Please?
Thanks for reading and/or replying to this post
Malice
Texas USA