#include <stdio.h> #include <string.h> #include <stdlib.h> #include <conio.h> #include <tvplib.h> //my header locates string_check() function int main() { char str1[11], str2[11], str3[5]; int i; printf("Enter first string: "); fgets(str1, 11, stdin); for (i=0; i<11; i++) if (str1[i]=='\n') { str1[i]='\0'; break; } printf("String 1: %s Length: %d\n", str1, strlen(str1)); printf("Enter second string: "); fgets(str2, 11, stdin); for (i=0; i<11; i++) if (str2[i]=='\n') { str2[i]='\0'; break; } printf("String 2: %s Length: %d\n", str2, strlen(str2)); printf("Result: %d\n",strcmp(str1,str2)); printf("Enter password from keyboard: "); i=0; str3[i]='\0'; while ((i<4) && (str3[i]!='\n')) { str3[i]=getch(); if (str3[i]== '\n') { break; } puts("*"); i++; }; printf("String str3 value: %s\n", str3); if (string_check(str3) == 0) { printf("Correct Password: %s", str3); } else printf("Wrong Password: %s", str3); getch(); return 0; }
if (str3[i]== '\n') { str3[i] = '\0'; break; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)