I tried to follow the steps but I'm getting this error
"undefined reference to 'WinMain@16'" while I try to compile stringutils.c, here's the code
stringutils.c
Code:
#include <stdio.h>
#include <string.h>
#define MAXLEN 1000 /* max length of any input line */
int getline(char *, int);
char *alloc(int);
/* readlines: read input lines */
int readlines(char *lineptr[], int maxlines)
{
int len, nlines;
char *p, line[MAXLEN];
nlines = 0;
while((len = getline(line, MAXLEN)) > 0)
if(nlines >= maxlines || (p = alloc(len)) == NULL)
return -1;
else
{
line[len-1] = '\0'; /* delete newline */
strcpy(p, line);
lineptr[nlines++] = p;
}
return nlines;
}
/* writelines: write output lines */
void writelines(char *lineptr[], int nlines)
{
int i;
for(i = 0; i < nlines; i++)
printf("%s\n", lineptr[i]);
}
/* getline: get line into s, return length */
int getline(char s[], int lim)
{
int c, i;
i = 0;
while(--lim > 0 && (c = getchar()) != EOF && c != '\n')
s[i++] = c;
if(c == '\n')
s[i++] = c;
s[i] = '\0';
return i;
}
char * alloc(int n)
{
}
here is the header file
stringutils.h
Code:
int readlines(char *lineptr[], int nlines);
void writelines(char *lineptr[], int nlines);
I'm using Dev-C++ to edit and compile the source files