From: <no...@so...> - 2002-09-16 21:22:29
|
Support Requests item #598009, was opened at 2002-08-20 16:55 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=202435&aid=598009&group_id=2435 Category: None Group: None Status: Open Priority: 5 Submitted By: Sébastien Audet (angelbass) Assigned to: Nobody/Anonymous (nobody) Summary: Undefined reference in winmain@16 Initial Comment: Here's a pretty simple prog that i learn in the K & R C learning docs, when i try to compile it i get the error Undefined reference in winmain@16,what does it mean? Have in mind that i've begin to learn C language yesterday so maybe its quite simple.. #include <stdio.h> /* Read one line from standard input, */ /* Copying it to line array (but no more than max chars). */ /* Does not place terminating \n in line array. */ /* Returns line length, or 0 for empty line, or EOF for end- of-file.*/ int getline (char line[], int max) { int nch = 0; int c; max = max - 1; /* leave room for '\0' */ while ((c = getchar()) != EOF) { if (c== '\n') break; if (nch < max) { line[nch] = c; nch = nch + 1; } } if (c == EOF && nch == 0) return EOF; line[nch] = '\0'; return nch; } ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2002-09-16 14:22 Message: Logged In: NO /* Try this */ #include <stdio.h> /* Read one line from standard input, */ /* Copying it to line array (but no more than max chars). */ /* Does not place terminating \n in line array. */ /* Returns line length, or 0 for empty line, or EOF for end- of-file.*/ /* Global declarations. */ int max = 25; char line[25]; int getline (char line[], int max) { int nch = 0; int c; max = max - 1; /* leave room for '\0' */ while ((c = getchar()) != EOF) { if (c== '\n') break; if (nch < max) { line[nch] = c; nch = nch + 1; } } if (c == EOF && nch == 0) return EOF; line[nch] = '\0'; return nch; } int main() { getline( line, max); printf("This is my entry: %s\n", line); return 0; } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=202435&aid=598009&group_id=2435 |