User Tools

Site Tools


courses:programming:topic10

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
courses:programming:topic10 [2016/11/19 14:20]
kkv created
courses:programming:topic10 [2022/12/10 09:08] (current)
Line 1: Line 1:
-=== Динамические структуры ===+=== Загрузка данных из файла ​===
  
 +<code c++>
 +
 +// Programming 1. Sample at 2016-11-10-14-01.08
 +#include <​stdio.h>​
 +
 +struct Person
 +{
 +  char name[100];
 +  int age;
 +};
 +
 +
 +int main(/*int c, char **v */)
 +{
 +  struct Person data[5];
 +
 +  FILE *f = fopen("​a.txt","​r"​);​
 +
 +  //int ret = fscanf(f, "​\"​%s\"​ %d",​data.name,&​data.age);​
 +  fgets(data.name,​ 50, f);
 +
 +  printf("​[%s]\n",​data.name);​
 +  ​
 +  for(int i=0;​i<​5;​i++)
 +    printf("​%s,​ age %d\n",????​);​
 +
 +  return 0;
 +}
 +</​code>​
  
courses/programming/topic10.1479565217.txt.gz · Last modified: 2022/12/10 09:08 (external edit)