Thread: line 10: incompatible types in initializer

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    2

    line 10: incompatible types in initializer

    Hi Friends

    I am new to C programming. I am using C compiler of Miracle C.
    I am using header stdio.h only.

    I am getting this compile Error.

    line 10: incompatible types in initializer



    short jansold=23500;
    short febsold=19300;
    short marsold=21600;
    float Revquarter=0.0f;

    long quartersold = jansold + febsold + marsold ; // line 10

    I really dont know what is wrong here. I have a doubt that might be i need any header file.
    Any help or suggestion would be greatly appreciated.

    Thanks
    Regards

    Veronica

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Should compile ok. But with Miracle C you never know.
    You'd overflow a short anyway
    I'd try
    Code:
    long quartersold =(long)jansold +(long) febsold +(long) marsold; // line 10
    Kurt

  3. #3
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    Yeah it does compile OK with the compiler i'm using (MSVC++ 6.0) and i couldn't say why you are getting an error.

    By the way, i don't know the Miracle C compiler.

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    2
    hi Zuk

    Thanks for the reply. I just give type (long) and it works fine now.

    thanks

    Veronica.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > I am new to C programming. I am using C compiler of Miracle C.
    Your problem is that Miracle C is a PoS. It routinely fails to compile even the most trivial of programs.

    Get say visual studio express, or perhaps the code::blocks IDE with the MinGW compiler (available as a single downloadable package).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help again with scrolling without wrapping
    By Dukefrukem in forum C Programming
    Replies: 8
    Last Post: 09-21-2007, 12:48 PM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 01:34 PM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. Heaps...
    By Nutshell in forum C Programming
    Replies: 14
    Last Post: 04-23-2002, 08:54 AM