#19 Undefined reference in winmain@16

closed
nobody
None
5
2014-08-17
2002-08-20
No

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;
}

Discussion

  • Sébastien Audet

    the exact same code as in the windows

     
  • Nobody/Anonymous

    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;
    }

     
  • Earnie Boyd

    Earnie Boyd - 2003-01-03
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks