Problem: far to near copy, and vice versa

This is a discussion on Problem: far to near copy, and vice versa within the C Programming forums, part of the General Programming Boards category; Could someone tell me what is wrong with this? Code: static byte response_string[300]; static byte far far_response_string[3500]; _fstrncpy( far_response_string, "hi", ...

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    28

    Problem: far to near copy, and vice versa

    Could someone tell me what is wrong with this?

    Code:
    static byte	response_string[300];
    	
    static byte far	far_response_string[3500];
    
    
    _fstrncpy( far_response_string, "hi", 3 );
    
    response_string[0] = far_response_string[1];
    
    goto_lcd(0,1);
    sprintf( _temps, "%c", response_string[0] );
    puts_lcd( _temps );
    What i get on the lcd is nothing (null)

    I have a feeling that the
    Code:
    response_string[0] = far_response_string[1];
    line is copying it as a null.

    I've tried casting the far_response_string[0] to a (byte) also but with the same problem, the scary thing is that the compiler doesn't complain. I would have expected a suspicious pointer conversion warning if it was a casting issue.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem: 64k block issue
    By aaronc in forum C Programming
    Replies: 1
    Last Post: 06-16-2004, 04:22 AM
  2. copy constructor/type converter?
    By kny in forum C++ Programming
    Replies: 2
    Last Post: 03-13-2002, 10:44 PM

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