Advertisement
Niloy007

Structure & File

Feb 24th, 2021
905
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.46 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main() {
  4.     FILE *ptr;
  5.     ptr = fopen("text.txt", "w");
  6.  
  7.     if (ptr == NULL) {
  8.         printf("File does not exist\n");
  9.     } else {
  10.         char ch[50];
  11.         gets(ch);
  12.         fprintf(ptr, "%s", ch);
  13.         printf("Updated!\n");
  14.     }
  15. }
  16.  
  17. // long long check(long long n) {
  18. //  int count = 0;
  19. //  while (n > 0) {
  20. //      n = n / 10;
  21. //      count++;
  22. //  }
  23. //  return count;
  24. // }
  25.  
  26. // int main() {
  27. //  long long number;
  28. //  scanf("%lld", &number);
  29. //  long long res = check(number);
  30. //  // printf("%lld\n", res);
  31. //     if (res == 11) {
  32. //      printf("Condition true\n");
  33. //  } else {
  34. //      printf("Condition false\n");
  35. //  }
  36. // }
  37.  
  38. // struct student {
  39. //  char name[50];
  40. //  int roll;
  41. //  int phoneNo;
  42. // };
  43.  
  44.  
  45.  
  46. // int main() {
  47. //  struct student s1[50];
  48. //  int size;
  49. //  printf("How many students you have?\n");
  50. //  scanf("%d", &size);
  51.  
  52. //  for (int i = 0; i < size; i++) {
  53. //      printf("Enter Name: \n");
  54. //      fflush(stdin);
  55. //      gets(s1[i].name);
  56. //      fflush(stdout);
  57. //      printf("Enter Roll and Phone no: \n");
  58. //      scanf("%d %d", &s1[i].roll, &s1[i].phoneNo);
  59. //  }
  60.  
  61. //     for (int i = 0; i < size; i++) {
  62. //      printf("Name: %s\n", s1[i].name);
  63. //         printf("Roll: %d\n", s1[i].roll);
  64. //         printf("Phone No: %d\n", s1[i].phoneNo);
  65. //  }
  66. // }
  67.  
  68.  
  69. // int main() {
  70. //  struct student s1;
  71. //  gets(s1.name);
  72. //  scanf("%d %d", &s1.roll, &s1.phoneNo);
  73. //  printf("Name: %s\nRoll: %d\nPhone No: %d\n", s1.name, s1.roll, s1.phoneNo);
  74. // }
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement