Untitled

 avatar
unknown
plain_text
2 years ago
709 B
4
Indexable
#include <stdio.h>
#include <string.h>
#define PROMPT "Command(entry, display, quit)? "
#define STRING_DISPLAY "String?"
char entry(char* string);
char display();
main() 
{
	char* options[] = {"entry", "display", "quit"};
	char* choice[7];
	char entered[9] = "";
	char entry_input[9];
	printf(PROMPT);
	scanf("%s", &choice);
	while (strcmp(choice, options[2]) != 1){
		if ((strcmp(choice, options[1])) == 1) {
			printf(STRING_DISPLAY);	
			scanf("%s", &entry_input);		
			strncat(entered, entry_input, 9);
		}
		else if((strcmp(choice, options[2])) == 1){
			printf("%s", entered);
			if(entered == '\n') {
				printf("no data");
			}
		}
		else if(strlen(choice) > 7) {
			printf("command too long");
		}	
	
Editor is loading...