为什么打印不出东西
以下代码没有报错,但是打印不出东西,请问是不是哪里出了问题?#include "stdafx.h"
#include "ctype.h"
#include "conio.h"
char *getword(char *word, int lim) {
char *w = word;
int c, n;
while (isspace(c = _getch()))
;
if (!isalpha(c) && c != EOF) {
_ungetch(c);
return 0;
}
for (n = 0;n < lim, isalpha(c), c = _getch();n++) {
*word = c;
word++;
}
if (c != EOF)
_ungetch(c);
return w;
}
int main()
{
char s[20];
int lim = 3;
printf("%s\n", getword(s, lim));
return 0;
}