0

i couldn't get why i can't take a character pls help me:(

#include <stdio.h> #include <stdlib.h> void shiftRightOrLeft(int d[], int size, int n, char direction); int main() { int size,n; char direction; printf("size:"); scanf("%d",&size); int d[size]; int i; printf("dizi elemanlari:"); for(i=0;i<size;i++) { scanf("%d",&d[i]); } printf("n:"); scanf("%d",&n); printf("Enter if Left or Right: "); scanf("%c",&direction); shiftRightOrLeft( d,size, n,direction); return 0; } void shiftRightOrLeft(int d[], int size, int n, char direction) { if(direction=='l') { int temp=d[n-1]; int i; for(i=1;i<size;i++) { d[i-1]=d[i]; } d[size-1]=temp; int m; for(m=0;m<size;m++) { printf("%d",d[m]); } } else if(0==strcmp(direction,"r")) { int temp2=d[size-n]; int i; for(i=1;i<size;i++) { d[i]=d[i-1]; } d[0]=d[size-n]; } int k; for(k=0;k<size;k++) { printf("%d",d[k]); } }

3rd Apr 2020, 11:22 AM
Aylin
2 Answers
0
When prototyping function at the top, you should give return type
3rd Apr 2020, 11:40 AM
Salman Nazeer
Salman Nazeer - avatar
0
Thank you but it doesn't work still i have a problem with character
3rd Apr 2020, 12:12 PM
Aylin