I delete spaces, tabs, transitions to a new line in a text file (the text file itself is a program)

char sep [10]="\n"; char *istr; istr = strtok (A+107,sep); while (istr != NULL) { printf ("%s",istr); istr = strtok (NULL,sep); } 

I deviate 107 characters from the beginning of the line in order not to touch the declared libraries. But in the end, spaces cannot be removed in the same way. It turns out something like this:

 void vpqumlntyof(char *A ,char *O4gh){ int i = 0; int R0x1 = strlen(A); int Pd0x = strlen(O4gh); if (R0x1 == Pd0x) { while (i < strlen(A)) { if (A[i] == O4gh[i]) { i++; } else break; } if (i == strlen(A)) { puts("Correct"); } else { puts("InCorrect"); } } else puts("InCorrect");}int main(){ FILE *fp; fp = fopen("C:\\Users\\Elvin\\Documents\\Password_OIB_ETALON.txt" , "r"); char A[N]; char O4gh[80]; int i = 0; int j = 0; int dlina=0; int JBLhU9=0; fscanf(fp, "%s", &A) != EOF; puts(A); puts("\nEnter the O4ghword\n"); gets(O4gh); dlina=strlen(A); JBLhU9=strlen(O4gh);for(i=0;i<dlina;i++) { A[i]=A[i]^5; }puts(A);for(i=0;i<JBLhU9;i++){ O4gh[i]=O4gh[i]^5;}puts(O4gh); vpqumlntyof(A,O4gh); _getch(); return 8;} 

I would like to remove the spaces, but they do not move for some reason. And is it possible to insert a garbage code here, as when obfuscating?

  • Is space help? - Elvin
  • one
    And if the delimited string is made like this: char sep [10]=" \t\n"; ? - Vladimir
  • wow, you are right, thank you - Elvin
  • @Vladimir, please, make your comment in response so that Elvin could accept it as an answer to a question. - Evgeny Shalaev
  • one
    Just keep in mind that, in an amicable way, you cannot touch anything at all in string literals in the program, and you cannot remove some spaces, for example, somewhere in const volatile i . Or end the line after the comment or #include ... - Harry

1 answer 1

Make a delimited string like this: char sep [10]=" \t\n";

  • one
    It is not entirely clear why the explicit size is 10 . - AnT
  • @AnT, this is also a mystery to me. Yes, you could not explicitly specify the size of the array. But I don’t know how the author of the question is going to use this array further - maybe it was supposed to save other strings there too? I do not know the exact formulation of the problem (although, since there was more about obfuscating, then you can try to turn on the fortune teller mode, yes). And in such conditions I try to answer a specific question with a minimum of changes in the author's code. Do you think I'm wrong? - Vladimir