Ok. So I added this:
Code:
while(scanf("%d",&a) && a != 0){
Like always, It still encodes the number itself which I don't get how to stop because it should ask for the next input.
For Example.. I put in 5 and hit enter and I get * on the next line.
Now this is where I usually put in the actual sentence to encode which it normally did, but now with the new condition added to the while() loop, when I put in the new sentence and hit enter the program exits.
But it actually also exits when it finds a 0, but doesn't work now.
Any idea?
Here's the full updated code:
Code:
int main(void){
int i,a;
char sent[100];
while(scanf("%d",&a) && a != 0){
fgets(sent,sizeof(sent),stdin);
for(i=0;sent[i];i++){
if(sent[i] == ' ')
sent[i] = ' ';
else if((sent[i] + a) > 'Z')
sent[i] = 'A' + ((sent[i] + a) - 'Z')-1;
else
sent[i] += a;
}
printf("%s\n",sent);
}
return 0;
}