Skip to content

Commit

Permalink
Embarrasing mistake. Always return 1 on error
Browse files Browse the repository at this point in the history
  • Loading branch information
hesa committed Nov 15, 2016
1 parent 8a67088 commit 8aff990
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions hand-in/calculator/expression.c
Expand Up @@ -20,15 +20,15 @@ comp_str(char* a, char* b)
{
if(a==NULL || b==NULL)
{
return -1;
return 0;
}

/* Perhaps a bit overly optimised, but we like to make you think about this one
* If two strings are of different length they can't be "equal"
*/
if (strlen(a)!=strlen(b))
{
return -1;
return 0;
}
return strcmp(a,b)==0;
}
Expand All @@ -44,8 +44,8 @@ string_to_op(char *str)
*/
while (op_strings[(int)++i]!=NULL)
{
/* printf ("i: %d %s %s \n", */
/* i, op_strings[i],str); */
printf ("i: %d %s '%s' \n",
i, op_strings[(int)i],str);
if (comp_str(op_strings[(int)i],str))
{
return i;
Expand Down

0 comments on commit 8aff990

Please sign in to comment.