Thread: A warning of strange meaning

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688

    A warning of strange meaning

    I have seen this warning a few times when I compile this line of code, the warning is this:

    warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data

    The code is this:

    Code:
    char senta[]="I am an example!"
    
                size=strlen(senta);
                for(x=0;x<size;x++)
                {   
                    Sleep(40); 
                    printf("%c",senta[x]);
                }
    Sorry if the indents a little rubbish, but the warning it produces does not change my output.. what does it mean? I have looked
    in my compiler log and can't find the answer...

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    size is (presumably) declared as type int and strlen is returning a value of type size_t.
    You can remove this warning by declaring size as size_t
    Code:
    size_t size;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM