This code is producing the strange output below. I tried increasing the character array to be 13 and it printed the whole string, but still had the strange characters at the end. I'm using MinGW on Windows. Could that be the cause?
#include <stdio.h> #include <string.h> int main() { char message[10]; int count, i; strcpy(message, "Hello, world!"); printf("Repeat how many times? "); scanf("%d", &count); for(i=0; i < count; i++) printf("%3d - %s\n", i, message); if(i==count) getch(); } 