I've have about 4 good hours of practice with .c filesCode:// classs1234.cpp : main project file. #include "stdafx.h" #include <stdio.h> #include <string.h> #define MAX_REMIND 50 #define MSG_LEN 60 int read_line(char str[], int n); using namespace System; int main(array<System::String ^> ^args) { char reminders[MAX_REMIND][MSG_LEN+3]; int len=strlen(t1); printf("%d", len); char day_str[3], msg_str[MSG_LEN+1]; int day, i, j, num_remind = 0; for (;;) { if ( num_remind == MAX_REMIND ) { printf("--No space left--\n"); break; } printf("Enter day and reminder: "); scanf("%2d", &day); if (day == 0 ) break; sprintf(day_str, "%2d", day); read_line(msg_str, MSG_LEN); for ( i = 0; i < num_remind; i++ ) if ( strcmp( day_str, reminders[i]) < 0 ) break; for ( j = num_remind; j > i; j-- ) strcpy( reminders[j], reminders[j - 1] ); strcpy( reminders[i], day_str ); strcat( reminders[i], msg_str ); num_remind++; } printf("\nDay Reminder\n"); for ( i = 0; i < num_remind; i++ ) printf(" %s\n", reminders[i]); return 0; } int read_line(char str[], int n ) { char ch; int i = 0; while ( ( ch = getchar() ) != '\n' ) if ( i < n ) str[i++] = ch; str[i] = '\0'; return i; }
I did not write the code above and barely understand
directives,Char var, statements and so on
the code above is the code i plan to pick apart to
start my adventure learning C programming
any advise as to why the code will not return any value after a keystroke . It simply ignores everything. maybe this is my
fault by not telling it to do so.
what should i do to get this to recognize words and so on?