Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 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!='*'){
  58. c = fgetc(in);
  59. if (c=='\n') printf("\n");
  60. }
  61. //printf("\npochti zashli\n");
  62. //printf("\nSeychas c=%c\n",c);
  63. if (c=='*') {
  64. //printf("zashli");
  65. d = fgetc(in);
  66. //printf("%c",d);
  67. }
  68. }
  69. }
  70.  
  71.  
  72. }
  73.  
  74. }
  75. /*while ((c = fgetc(in))!= EOF){
  76. if (c!='\n') printf("%c\n",c);
  77. else printf ("%c",c);
  78. }*/
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement