I have a problem with reading strings in c. When I add the gets() function in an if-instruction, the program stops.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n,i = 0;
    char sir[2000],ch;
    printf("Press you option: "); scanf("%d",&n);
    if(n == 1)
    {
        printf("text: "); gets(sir);
        printf("\nINPUT: ");
        for(i = 0;i < strlen(sir);i++)
            printf("%c",sir[i]);
    }
    return 0;
}
Any solution?
 
     
     
     
    