Advertisement
hawk420

Untitled

Dec 10th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6. char *headings[6][40] ;
  7.  
  8. struct data {
  9. int id;
  10. char first_name[50];
  11. char last_name[50];
  12. char email[50];
  13. char male[50] ;
  14. char ip[50] ;
  15. } ;
  16.  
  17. struct data ** mydata;
  18.  
  19. int main() {
  20. int liczba=2027;
  21. FILE *fp = fopen("tabela.csv", "r") ;
  22. mydata = (struct data **)malloc(liczba*sizeof(int));
  23.  
  24. for(int i=0; i<liczba; i++)
  25. mydata[i]=(struct data *)malloc(sizeof(struct data));
  26.  
  27. if ( fp != NULL ){
  28. for(int i=0; i<liczba; i++){
  29.  
  30. fscanf(fp, "%s, %s, %s, %s, %s",
  31. mydata[i]->first_name, mydata[i]->last_name,
  32. mydata[i]->email, mydata[i]->male,
  33. mydata[i]->ip );
  34.  
  35. }
  36. }
  37.  
  38. for (int j=0; j<liczba; j++){
  39. printf("%d %s %s %s %s %s\n",
  40. mydata[j]->id, mydata[j]->first_name,mydata[j]->last_name,
  41. mydata[j]->email, mydata[j]->male,
  42. mydata[j]->ip );
  43. }
  44. for(int i=0; i<liczba; i++)
  45. free(mydata[i]);
  46. return 0;
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement