Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


sorry HELP!!!! again

kkocikkkocik Member Posts: 13
sorry i just have another question.....

when you have something stored in a char* word.... say the words Oct ...

now you want to compare this...

if(word = 'Oct')
... this doesn't work... why? and how can i rectify it... i get the warning "makes integer from pointer without cast"... i tried casting it but that still doesn't work...

please help
thank you in advance


  • First of all use '==' for testing values, '=' is for assigning values.

    The compiler give this error because what you are trying to do is assign word with 'Oct' (also in C strings are in " "'s). The way you test if strings are the same in C is like this


    int main(void) {
    if(!strcmp(word,"Oct")) {
    // word == "Oct"
    } else {
    // word != "Oct"

    Also notice that strcmp will return false when a string matches so you have to ! it to make it work the way you want. Why cant there be any order in the world ay :P
  • Justin BibJustin Bib USAMember Posts: 0

    ________ || || free ebooks and video tutorials about [ Python Ruby Go Java Objective-C R JavaScript C++ Assembly Swift Visual Basic .NET PL/SQL Perl Visual Basic C Delphi C# MATLAB Scratch PHP LabVIEW Julia ML Lua Transact-SQL Dart Apex Kotlin Alice Lisp Crystal Awk F# D VBScript Erlang Scheme Fortran Rust Ada Hack Clojure FoxPro ABAP COBOL Prolog Scala Bash SAS Logo ] __

Sign In or Register to comment.