I have the following code
Code:
#include <stdio.h>
#include <conio.h>
int main(void)
{
char *ptrchar1;
char first_line[10];
ptrchar1=&first_line;
printf("What is the keyword?");
while( scanf("%c",ptrchar1)==1)
{
if(*ptrchar1=='\n')
{
*ptrchar1='\0';
break;
}
ptrchar1++;
}
printf("\n\nThe first word is %s",&first_line);
getch();
return 0;
}
is there a way i can get away without allocating 10 chars in the statement
char first_line[10];
i mean what if i had a keyword of 12 chars which i would want to fit in, then what?