I'm a newbie programmer. I have an assignment and I have some troubles about that. First of all my assignment is :
"Assume that you scan the input text in Turkish character by character from the keyboard, which you may think of as a default input device, until a ‘CTRL-D’ is pressed. You are supposed to skip punctuation characters as well as blank character. Your program will display the frequencies of letters and digits whenever the scanning process is done. You need to discuss the data structure as well as flowchart solution and hand in them with your code."
I did some research and found that the CTRL + D command corresponds to EOF. I wrote my code but it doesn't work as I want. Here is my code.
#include <stdio.h>
#include "stdlib.h"
#include <locale.h>
int main()
{
setlocale(LC_ALL, "Turkish");
char message[1000] = { ' ' };
char ch;
int i = 0;
printf("Please enter your message: ");
while (ch = getchar() != EOF )
{
message[i] = ch;
i++;
}
for (i; i >= 0; i--)
{
printf("%c", message[i]);
}
printf("\n\n");
system("PAUSE");
return 0;
}
When I run it, I write something and press ctrl + d, but as you can see in the picture, nothing happens. It just writes ^ D. Thank you for your help.