Thread: Multiplication problem

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, it doesn't complain even with language extensions OFF. I don't know what the correct code if that's not correct. Perhaps someone else you fix it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I don't know what the correct code if that's not correct.
    Eh, the old C-style casts:
    Code:
    z += ((float)5 - (float)y) * h2;
    except that now it isn't just C-style, it is C.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #18
    Registered User
    Join Date
    Feb 2008
    Posts
    147
    Quote Originally Posted by laserlight View Post
    It should yield a compile error since this is C

    I think Kempelen's ( 5 - (int) y) * h2 works, and Kempelen has stated as much. What does not work is the original program when this change is incorporated, but we cannot help debug something that we have no knowledge of.
    You are correct. It works, I had a bug in the original programs that I have just fixed it.

    Thanks all for the help..... I am learning that a lot of care must be taking when mixing different types of vars......

    FS

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by laserlight View Post
    Eh, the old C-style casts:
    Code:
    z += ((float)5 - (float)y) * h2;
    except that now it isn't just C-style, it is C.
    I just did that (I updated the code, too). I always use C-style casts, so I'm pretty used to them.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #20
    Registered User
    Join Date
    Dec 2007
    Posts
    214
    Quote Originally Posted by matsp View Post
    Of course it does. You may get a warning for converting float to int, but it "works" in the respect that it does roughly what you expect.

    --
    Mats
    I misread. I thought he was expecting a floating point number in his x variable.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. ...multiplication using stacks
    By iiwhitexb0iii in forum C Programming
    Replies: 1
    Last Post: 10-09-2006, 01:28 AM

Tags for this Thread