TextOut Problem !

This is a discussion on TextOut Problem ! within the C++ Programming forums, part of the General Programming Boards category; I want to display the fps for my app. heres part of my code: Code: case WM_PAINT: TextOut(hDC,1,1,fcount,lstrlen(fcount)); //fcount = ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    27

    TextOut Problem !

    I want to display the fps for my app. heres part of my code:

    Code:
     case WM_PAINT:
     TextOut(hDC,1,1,fcount,lstrlen(fcount)); //fcount = int
    I cant make it 4 fields but i cant get the length of a int so what do you do for this ?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    Use sprintf to convert the int to a string
    Code:
    char buff[20];
    sprintf( buff, "%d", fcount );
    TextOut(hDC,1,1,buff,lstrlen(buff));

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    27
    i tried that but the compiler said sprintf was a undeclared identitifier ?

  4. #4
    Xei
    Xei is offline
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719
    Make sure that you include iostream.h

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    194
    You want to include <stdio.h> to use sprintf

  6. #6
    Registered User Liam Battle's Avatar
    Join Date
    Jan 2002
    Posts
    114
    I suggest dont use Sprintf() use the atoi(); or itoa() for conversions.

    it has more options if you are using MSVC++...
    also look at _atio() and _itoa() in the MSDN library
    LB0: * Life once school is done
    LB1: N <- WakeUp;
    LB2: N <- C++_Code;
    LB3: N >= Tired : N <- Sleep;
    LB4: JMP*-3;

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, 10: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. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM

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