I am trying to make a program that will take a file name and print the characters after the period. Ex: "text.cpp" will be turned into "cpp" The program is sort of working. I am not sure how to make the program print more than one character. All it does is print the first character and if there is more than one character after the period it doesn't print it. Any help is appreciated.
Code:#include <stdio.h> int main() { char fname[50]; int x=0; printf("Enter filename: "); scanf("%s",fname); while(x < strlen(fname)) { x++; if(fname[x] == '.') { x++; printf("%c", fname[x]); return 0; } printf("Error: invalid entry!"); return 0; }