Returning result of an external function

This is a discussion on Returning result of an external function within the C Programming forums, part of the General Programming Boards category; Hi, if anyone can help me I will be eternally greatful.. and etc.. I'm writing an os, I know alot ...

  1. #1
    Unregistered
    Guest

    Returning result of an external function

    Hi, if anyone can help me I will be eternally greatful.. and etc..

    I'm writing an os, I know alot about asm but lack any knowledge of c.
    Bascially, I've written an input function in asm that returns what the user typed. I have no trouble just using the name to load a program or to print what was typed to screen, but I can't perform and if on the input without getting a warning. Ive tried messing around with changing ints to chars and stuff, but with my lack of knowledge im really stuck. The code is below:
    (The eroor I get is warnging: comparison between integer and pointer)

    extern void printf();
    extern void pause();
    extern void reboot();
    extern void cls();
    extern input();
    extern void loadprogram();

    static int i;

    int main(void)
    {
    printf("Kernel loaded\n\r");
    printf("Press a key to clear screen\n\r");
    pause();
    cls();
    printf("Command?");
    i=input();
    command(i);
    pause();
    }

    int command(i)
    {
    if (i=="run") {
    printf("Filename of progra to run?\n");
    i=input();
    loadprogram(i);
    }
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > (The eroor I get is warnging: comparison between integer and
    > pointer)

    Yeah, and you know why it gives you that?

    > int command(i)
    > {
    > if (i=="run") {

    Because you're comparing an INTEGER AND A POINTER!!

    See that last line? You cannot use == for comparison. Use strcmp. Or better yet, fix your function prototype to take a char* first, then use strcmp.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  2. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01:28 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21