Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include <string.h>
  4. int main(void)
  5. {
  6. FILE *in;
  7. char ch = getc(stdin);
  8. if(ch == '\n')
  9. {
  10. printf("Name hasn't been entered\n");
  11. exit(1);
  12. }
  13. int count = 1;
  14. char * mem = (char *) malloc(sizeof(char));
  15. *(mem) = ch;
  16. while(ch!='\n')
  17. {
  18. mem = (char *) realloc(mem, sizeof(char)*(count+1));
  19. ch = getc(stdin);
  20. *(mem+count) = ch;
  21. count++;
  22. }
  23. mem = (char *) realloc(mem, sizeof(char)*(count+1));
  24. int number=0;
  25. while (mem[number]!='\n')
  26. {
  27. printf("%c",mem[number]);
  28. number++;
  29. }
  30. printf("%i;%i\n",number,count);
  31. char mass[number];
  32. for(int d = 0; d < number; d++)
  33. {
  34. mass[d] = *(mem+d);
  35. }
  36. in = fopen(mass, "r");
  37. if (in == NULL)
  38. {
  39. printf("\n Error \n");
  40. }
  41. else
  42. {
  43. int c;
  44. int d;
  45. while ((c = fgetc(in))!= EOF){
  46. if (c!='/') printf ("%c",c);
  47. else {
  48. c = fgetc(in);
  49. if (c=='/'){
  50. while ((c = fgetc(in))!= '\n');
  51. if (c=='\n') printf("\n");
  52. continue;
  53. }
  54. if (c=='*'){
  55. while (d!='/'){
  56. c=fgetc(in);
  57. while (c!='*') c = fgetc(in);
  58. //printf("\npochti zashli\n");
  59. //printf("\nSeychas c=%c\n",c);
  60. if (c=='*') {
  61. //printf("zashli");
  62. d = fgetc(in);
  63. //printf("%c",d);
  64. }
  65. }
  66. }
  67.  
  68.  
  69. }
  70.  
  71. }
  72. /*while ((c = fgetc(in))!= EOF){
  73. if (c!='\n') printf("%c\n",c);
  74. else printf ("%c",c);
  75. }*/
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement