compilation problem

By cibiieph
Apr 5, 2006
  1. Hi everyone,

    I've been trying to compile a short porgram in C that uses the sprintf() funcion
    I get the following compilation error:

    /user/bin/sh: -c:Line1: syntax error near unexpected token 'fi'

    Any suggestions as to fixing this error?
  2. Spike

    Spike TS Evangelist Posts: 2,168

    :wave: Welcome to Techspot :wave:

    Not that I'm a c/c++ programmer or anything, but given that it's a syntax related error, might it be useful to post your code? (as a txt attachment if there's a lot of it)
  3. cibiieph

    cibiieph TS Rookie Topic Starter

    Hi Spike,
    Thanks for the quick reply
    this is the code:

    #include <cstdio.h>
    void printNumber(int number)
    byte string[10];

    sprintf( string, "%d", number );

    void printString(char txt[])
    byte i;

  4. Spike

    Spike TS Evangelist Posts: 2,168

    That ones a bit beyond my VERY VERY basic C knowledge. There are a few people here that can really code in C though, and hopefully one of those might be able to help you.


    Are those spaces inside each side of the brackets supposed to be there?
  5. cibiieph

    cibiieph TS Rookie Topic Starter

    Hi everyone,

    Does anybody know how to get a hold of the <cstdio.h> and <stdlib.h> header files
    and add them to the Command Prompt compiler to compile a C program?
  6. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    As you see, this error is reported by the sh shell. You are running some shell script and there is an error in that script. Nothing to do with C++ or compilers.

    These headers should come with your C compiler. The exact syntax of specifying include paths depends on the compiler you use. For gcc you'd add "-I /some/additional/include/files/path" to the command line. Mind you, these standard headers should exist in standard locations and your compiler should find these all by itself. If your compiler fails to find these for some reason, try them without the .h suffix - the new C standard headers are without .h and .hpp extensions.
Topic Status:
Not open for further replies.

Similar Topics

Add New Comment

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...