What function should i use for comparing the last 3 characters of strings?
Hi all I am writing code for printing the all students' names whose average mark is prime number and whose last name (l_name) ends with "yan" what should I do? strstr() function does not help as it works from the first character and it's not excluded that "yan" can appear not at the end of string? I should check the ending #include <stdio.h> #include <string.h> #include <stdlib.h> struct student { char f_name[50]; char l_name[70]; int avg_mark; } void main() { int i,j; int n; scanf("%d", &n); student *x=(student*)malloc(n*sizeof(student)) for (i=0; i<n; i++) scanf ("%s%s%d", x[i].f_name, x[i].l_name, &x[i].avg_mark ); for (i=0;i<n;i++) for(j=2;j<=x[i].avg_mark/2;j++) if (x[i].avg_mark/j!=0) printf("%f", x[i].avg_mark); } thanks in advance