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 &lt; max\) \{ line\[nch\] = c; nch = nch + 1; \} \}
if (c == EOF && nch == 0)
return EOF;
line[nch] = '\0';
return nch;
}
the exact same code as in the windows
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' */
}
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;
}