How can i convert this do while loop within this segment of code into a for loop or while loop. My current attempt to change the do loop seems to work somewhat, but im having a problem where it does not go to the next line.
Code:
...
while(fgets(transinput,sizeof(transinput),in)!=NULL){
i=0;
do {
for(j=0;j<npos;j++){
transchar = transinput[i];
if(transchar != '\n' && transchar != '\0'){
transtemp[j] = transchar;
++i;
} else {
transtemp[j] = ' ';
}
}
for(ii=0;ii<npos;ii++){
fprintf(out,"%c", transtemp[decrypt[ii]]);
}
}
while(transchar != '\n' && transchar != '\0');
fprintf(out,"\n");
}
...
My current attempt to change it
Code:
i=0;
while(fgets(input3,sizeof(input3),file1)!=NULL){
ch = input3[i];
while(ch != '\0' && ch!='\n'){
for(j=0;j<npos;j++){
//ch = input3[i];
if(ch != '\0' && ch!='\n'){
temp[j] = ch;
++i;
} else {
temp[j] = ' ';
}
}
for(k=0;k<npos;k++){
fprintf(file2,"%c", temp[transposition[k]]);
}
}
fprintf(file2,"\n");
}