well bascially here i started with K&R excerises with remove tabes and spaces i m not sure why my programs works in my head it does but even in puesdo code i did it does but arr[j] sometimes get intilised to values before
#include <stdio.h>
#include <ctype.h>
#define STOP -1
int GetLine(char *SzBuff) {
int i=0;
char c;
for( i=0;(c=getchar())!='\n';i++) {
SzBuff[i]=c;
if(c==EOF) return -1;
}
SzBuff[i]='\0';
return i;
}
int IsDel(char c) {
if(c==' ' || c=='\t') return 1;
return 0;
}
void RemoveBlanks(char * SzString) {
int j=0;
while(*SzString) {
if(!IsDel(*SzString)) { //wtf why the hell does it keep incrementing !!!
SzString[j++]=*SzString;
//putchar(SzString[j]);//used for debug
//getchar();
//j++;
}
SzString++;//this should fucken end the loop why the hell it keep going on incrementing
}
SzString[j]='\0';
return;
}
int main(void)
{
char SzName[100];
while(GetLine(SzName)!=STOP) {
RemoveBlanks(SzName);
if(SzName[0]=='\0')//skip blank lines
continue;
puts(SzName);
}
return 0;
}
here in RemoveBlanks function
i made this puesdocode for it
while(string not = '\0')
if(not equal to characters specefied)
copyString to String[j] character by character
i don't know whats wrong in it ?