c - Error: Expected expression before char -


i new learning c , i'm having hard time figuring out syntax. keep getting [error] expected expression before char in compiler , wondering if 1 explain me. here's code:

#include <stdio.h>  void convert_weight(int x, char a[], int* y, char b[]) { int i; for(i=0; char a[i] != '\0';i++)      if(char a[i] == 'l') {          *y/2.2;     }        else {         if(char a[i] == 'k')         {          *y *2.2;     }     }   }  int main() {   char newline, = 'y';   int weight1, weight2; char units1[4], units2[4]; // length 4 because of '\0' while (another == 'y') {     printf("enter weight , units of weight (lbs or kgs)\n");     scanf("%d %s", &weight1, units1);     convert_weight(weight1, units1, &weight2, units2);     printf("%d %s = %d %s\nanother (y or n)\n", weight1, units1, weight2, units2);      scanf("%c%c", &newline, &another)    ;   }   return 0; } 

you don't need redeclare in :

for(i=0; char a[i] != '\0';i++) 

remove char on lines :

void convert_weight(int x, char a[], int* y, char b[]) {    int i;    for(i=0; a[i] != '\0';i++)    {        if(a[i] == 'l') {           *y /= 2.2;        }           else if(a[i] == 'k') {           *y *= 2.2;        }    } } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -