The fact is that I enter the n-th number of lines of type: surname date of birth city and the program should print the surname age city. The question is how to break the string so that the date can be calculated!

#define M 30 #define N 100 int main() { char s[N], s2[N],s3[N], dtm[N]; char array[M][N], n; int x, i; for (n = 0; n < M && s[0] != '\n'; ++n) { fgets(s, N, stdin); strcpy_s(dtm, s); sscanf_s(dtm, "%100s %d %100s", s2,100, &x, s3,100); x = 2017 - x; strcpy_s(array[n], dtm); } for (i = 0; i < n; i++) { printf("%s", ); } getchar(); return 0; } 

In one line, we set everything for example ( Иванов 1988 Иваново ).

  • Look at sscanf to read the data (in particular, the date) from the line, and then subtract this date from the current (get the age) - avp
  • Do not quite understand, can you detail? - user237701
  • For "more detail" you need to know the format of the data (especially dates) in the string. - avp
  • in one line we set everything for example (Ivanov 1988 Ivanovo) - user237701
  • Well, at least you open the sscanf documentation - everything is written there. - user1056837

0