North America Premier Soccer League
Would you like to react to this message? Create an account in a few clicks or log in to continue.

DIFFERENT CODE BROKEN WA?

3 posters

Go down

DIFFERENT CODE BROKEN WA? Empty DIFFERENT CODE BROKEN WA?

Post by Aker Sat Apr 09, 2011 10:24 pm

My gay function is not compiling because its not pointing to the 2 strings any reason why because i made it bool instead of int because i don't want it returning anything other than true or false.
I also set the delimeter to ('\0')
Code:

#include <stdio.h>
#include <Windows.h>

bool compstr(const char *charstr1, const char *charstr2)
{
   
    while(*charstr1==*charstr2)
    {
        if(*charstr1 == '\0')
            return 0;
        charstr1++;
        charstr2++;
    }


    return (char *)charstr1 - (char *)charstr2;
}

int main()
{

    if(!compstr("str", "str"))
    {
        printf("Strings Match.");
    }

    getchar();
    return 0;
}

Aker
Site Regular
Site Regular

PSL Awards : N/A
Posts : 32

Back to top Go down

DIFFERENT CODE BROKEN WA? Empty Re: DIFFERENT CODE BROKEN WA?

Post by meh Sun Apr 10, 2011 3:39 pm

Perhaps because your passing 2 strings into a function that's asking for parameter type char geek

meh
Site Beast
Site Beast

PSL Awards : 1 Award (Click to view)
Posts : 287

Back to top Go down

DIFFERENT CODE BROKEN WA? Empty Re: DIFFERENT CODE BROKEN WA?

Post by Aker Sun Apr 10, 2011 7:01 pm

meh wrote:Perhaps because your passing 2 strings into a function that's asking for parameter type char geek
No thats not it the strcmp() is coded in C not C++.

Aker
Site Regular
Site Regular

PSL Awards : N/A
Posts : 32

Back to top Go down

DIFFERENT CODE BROKEN WA? Empty Re: DIFFERENT CODE BROKEN WA?

Post by meh Sun Apr 10, 2011 7:48 pm

Aker wrote:
meh wrote:Perhaps because your passing 2 strings into a function that's asking for parameter type char geek
No thats not it the strcmp() is coded in C not C++.

Then you just answered your own question lol

meh
Site Beast
Site Beast

PSL Awards : 1 Award (Click to view)
Posts : 287

Back to top Go down

DIFFERENT CODE BROKEN WA? Empty Re: DIFFERENT CODE BROKEN WA?

Post by Aker Sun Apr 10, 2011 8:50 pm

FML, i forgot to point the const's to *
Im dumb

Aker
Site Regular
Site Regular

PSL Awards : N/A
Posts : 32

Back to top Go down

DIFFERENT CODE BROKEN WA? Empty Re: DIFFERENT CODE BROKEN WA?

Post by Dill Sun Apr 10, 2011 9:32 pm

Aker wrote:My gay function


lol
Dill
Dill
Site Nerd
Site Nerd

PSL Awards : 9 Awards (Click to view)
Posts : 748

Back to top Go down

DIFFERENT CODE BROKEN WA? Empty Re: DIFFERENT CODE BROKEN WA?

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum