c - scanf is not waiting for input -
i'm trying find bug here, still don't it. i've been debugging , googling , found close topics, there solutions don't need atm, , i'm curious why code not working: #include <stdlib.h> #include <string.h> #include <stdio.h> #define buffer 256 int main() { int missioncode; char *desc = (char*)malloc(sizeof(char)*buffer); { printf("please enter mission code (or -1 exit): "); scanf("%d", &missioncode); fflush(null); if (missioncode==-1) return 1; } while (missioncode>10); { printf("please enter string:\n"); scanf("%[^\n]s", desc); //it doesn't stop here! fflush(null); if (!strcmp("exit",desc)) return 1; } while (strlen(desc)<20); printf("your string:\n%s", desc); return 0; } there's wrong scanf\flushall in second loop, don't find out what....