Is C different today than it was 1996?
I´m wondering cuz i have a book from that year and most of the tutorials don´t work.
Is C different today than it was 1996?
I´m wondering cuz i have a book from that year and most of the tutorials don´t work.
>Is C different today than it was 1996?
Yes and no. A new standard was ratified in 1999, but it's not widely implemented yet. So we continue to use the language definition set in place in 1990.
>I´m wondering cuz i have a book from that year and most of the tutorials don´t work.
It's more likely that your book uses tons of non-portable stuff that doesn't work anymore. What book, what compiler, and show us an example program.
My best code is written with the delete key.
this program does´nt work and it´s the easiest one:
when i run this i just recieves error messagesCode:#include <stdio.h> main ( ) { printf("Hello world!\n"); }
Well it's time you started reading them. They're there for a reason. Take the first one, fix it, recompile. Repeat until you have no warnings or errors.
Quzah.
Hope is the first step on the road to disappointment.
> when i run this i just recieves error messages
You still didn't say what book or what compiler.
And now I'll add "what error messages"
Please don't tell me you're using that piece of crap known as miracle c
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
here´s another one that´s don´t working:
I use Bloodshev dev c++, and borland c++. the error messages is:3:23 C:\Dev-Cpp\Daniels test.c [Warning] extra tokens at end of #include directiveCode:#include <stdio.h> #include <stdlib.h> /* För calloc */ #include <string.h> / För strdup */ /* Här deklareras en datastruktur */ struct kompis { char* namn; /* namn på en vän */ unsigned char alder; /* Ålder */ struct kompis* nesta; /* Nästa struct */ }; /*Funktionsdeklarationer */ struct kompis* Nykompis(const char* namn); struct kompis* SorteraIn(struct konmpis* ny, const struct kompis* rot); void Visapolare(const struct kompis* rot); /*om denna funktion inte finns i STRING.H */ /* char* strdup(char* orig); */
17 C:\Dev-Cpp\Daniels test.c [Warning] "struct konmpis" declared inside parameter list
17 C:\Dev-Cpp\Daniels test.c [Warning] its scope is only this definition or declaration, which is probably not what you want
[Linker error] undefined reference to `WinMain@16'
17 C:\Dev-Cpp\Daniels test.c ld returned 1 exit status
And the book is: Lättpocket om c-programmering it´s swedish...
should beCode:#include <string.h> / För strdup */
KurtCode:#include <string.h> /*För strdup */
1. strdup() isn't a standard function.
It might work fine for you at the moment, but expect surprises if you move to another OS/Compiler.
2. Check your spelling
struct kompis* SorteraIn(struct konmpis* ny
3. [Linker error] undefined reference to `WinMain@16'
You have a main(), for a console project
You set up a gui project, which expects winMain()
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
@Salem (3): He's using Dev-C++, which means he's using MinGW. MinGW does throw that error when you do not define main().
Maybe you'd want to check out the cprogramming.com online tutorials, they are written by our own members and all feature standard code.
And most of them are warnings. Not that you shouldn't ignore them, but they will not cause the compiler to stop. Heck, your code compiles properly. But it does not link because you do not define main(). And the program will do nothing in any case.
Looks like a linked list implementation to me.
Code:#include <stdio.h> void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){ puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9 /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i] ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][ t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}
> But it does not link because you do not define main().
The linker error would be undefined reference to main if that were the case.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Now i just get this error: 22:1 C:\Dev-Cpp\Untitled1.c unterminated commentCode:#include <stdio.h> #include <stdlib.h> /* För calloc */ #include <string.h> /* För strdup */ /* Här deklareras en datastruktur */ struct kompis { char* namn; /* namn på en vän */ unsigned char alder; /* Ålder */ struct kompis* nesta; /* Nästa struct */ }; /*Funktionsdeklarationer */ struct kompis* Nykompis(const char* namn); struct kompis* SorteraIn(struct kompis* ny, const struct kompis* rot); void Visapolare(const struct kompis* rot); /*om denna funktion inte finns i STRING.H */ /* char* strdup(char* orig);
Code:/* char* strdup(char* orig); */
> /* char* strdup(char* orig);
Can you spot the closing comment on this line?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I fixed the code like you said and now i get this error: [Linker error] undefined reference to `WinMain@16'Code:#include <stdio.h> #include <stdlib.h> /* För calloc */ #include <string.h> /* För strdup */ /* Här deklareras en datastruktur */ struct kompis { char* namn; /* namn på en vän */ unsigned char alder; /* Ålder */ struct kompis* nesta; /* Nästa struct */ }; /* Funktionsdeklarationer */ struct kompis* Nykompis(const char* namn); struct kompis* SorteraIn(struct kompis* ny, const struct kompis* rot); void Visapolare(const struct kompis* rot); /*om denna funktion inte finns i STRING.H */ /* char* strdup(char* orig); */
ld returned 1 exit status
C:\Dev-Cpp\Makefile.win [Build Error] [Project2.exe] Error 1
That's because there is no main() function.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)