Jump to content

Hey guys, I've been stuck on this error code for a couple hours and I have no idea what I should change

Here is my code.  Any help is appreciated. Below is the error code I am getting

 

 

 

Thanks, CJ 

Screenshot (2).png

i5 4670k| Asrock H81M-ITX| EVGA Nex 650g| WD Black 500Gb| H100 with SP120s| ASUS Matrix 7970 Platinum (just sold)| Patriot Venom 1600Mhz 8Gb| Bitfenix Prodigy. Build log in progress 

Build Log here: http://linustechtips.com/main/topic/119926-yin-yang-prodigy-update-2-26-14/

Link to comment
https://linustechtips.com/topic/541329-c-compilation-error/
Share on other sites

Link to post
Share on other sites

On line 161, what is this meant to be doing?:

int compare(guess, questionOne);

It looks like you are trying to call a function called "compare" and assign the result to an int. If this is the case it should be done as follows:

int x = compare(guess, questionOne);

But I can't see where the compare(char[][], char[]) function is defined.

 

The function strcmp takes two parameters, each of type const char* (a string). When you call strcmp you are passing a char and a bool. The error is saying that a char cannot be converted to a const char* and a bool cannot be converted to a const char*

 

In: 

strcmp(questionOne[j],guess[i] == 0) 

The first parameter is a single char and the second parameter is "guess == 0" which is a bool.

 

I believe what you are wanting to do is:
 

strcmp(questionOne, guess[i]) == 0

Which checks if questionOne equals guess , but I'm not even sure what your compare function is meant to do.

Edited by PlutoNZL
Link to comment
https://linustechtips.com/topic/541329-c-compilation-error/#findComment-7167873
Share on other sites

Link to post
Share on other sites

26 minutes ago, PlutoNZL said:

EDIT: Sorry I should read better. Give me a few minutes to correct my post

 

The function strcmp takes two parameters, each of type const char* (a string). When you call strcmp you are passing a const char* and a bool. The error is saying that a bool cannot be converted to a const char*

 

In: 


strcmp(questionOne[j],guess[i] == 0) 

the second parameter is "guess == 0" which is a bool.

 

I believe what you are wanting to do is:
 


strcmp(questionOne[j], guess[i]) == 0

Which checks if questionOne[j] equals guess

Currently getting this after changing that

145465749676541.png

i5 4670k| Asrock H81M-ITX| EVGA Nex 650g| WD Black 500Gb| H100 with SP120s| ASUS Matrix 7970 Platinum (just sold)| Patriot Venom 1600Mhz 8Gb| Bitfenix Prodigy. Build log in progress 

Build Log here: http://linustechtips.com/main/topic/119926-yin-yang-prodigy-update-2-26-14/

Link to comment
https://linustechtips.com/topic/541329-c-compilation-error/#findComment-7168018
Share on other sites

Link to post
Share on other sites

6 minutes ago, CJPowell27 said:

Currently getting this after changing that

145465749676541.png

The first argument you are passing to strcmp is a char when it should be a char*.

What are you wanting to compare? At the moment you are trying to compare a character with a string. 

 

I edited my post after you quoted it. Check out the updated code. 

Link to comment
https://linustechtips.com/topic/541329-c-compilation-error/#findComment-7168052
Share on other sites

Link to post
Share on other sites

7 minutes ago, PlutoNZL said:

The first argument you are passing to strcmp is a char when it should be a char*.

What are you wanting to compare? At the moment you are trying to compare a character with a string. 

 

I edited my post after you quoted it. Check out the updated code. 

Where would I change it to char*.  Sorry if it is a nooby question, the concept of functions and stuff is very new to me

i5 4670k| Asrock H81M-ITX| EVGA Nex 650g| WD Black 500Gb| H100 with SP120s| ASUS Matrix 7970 Platinum (just sold)| Patriot Venom 1600Mhz 8Gb| Bitfenix Prodigy. Build log in progress 

Build Log here: http://linustechtips.com/main/topic/119926-yin-yang-prodigy-update-2-26-14/

Link to comment
https://linustechtips.com/topic/541329-c-compilation-error/#findComment-7168098
Share on other sites

Link to post
Share on other sites

4 minutes ago, CJPowell27 said:

Where would I change it to char*.  Sorry if it is a nooby question, the concept of functions and stuff is very new to me

Char* is the same as char[] - an array of characters or a string. 

questionOne is an array of chars. questionOne[i ] is a single char. 

strcmp expects an array of chars such as questionOne. 

Link to comment
https://linustechtips.com/topic/541329-c-compilation-error/#findComment-7168125
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×