Return-Path: william@bourbon.usc.edu Delivery-Date: Fri Sep 5 18:47:53 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m861lq7d012633 for ; Fri, 5 Sep 2008 18:47:52 -0700 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id m861kFD6006734 for ; Fri, 5 Sep 2008 18:46:15 -0700 Message-Id: <200809060146.m861kFD6006734@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: ASCII string ?? Date: Fri, 05 Sep 2008 18:46:15 -0700 From: Bill Cheng Someone wrote: > For ADDR > > according to the specs, the IP address should be an ASCII string and not a > null terminated string....what exactly does this mean ?? > I am not sure about the difference between these two.. If you could please > explain .. A regular "string" is null-terminated. So, the string "Bob" take 4 characters where the last character is a '\0'. You can use strcpy() to copy strings like this becuase they look for the null-termination to decide when to end copying. If a string is not null-terminated, then it does not end with a '\0'. So, a non-null-terminated string "Bob" would take only 3 characters. You should not use functions such as strcpy() to copy strings like this because you don't know where it ends! You should use strncpy() and be explicit about the number of characters you copy. For our project, DataLength can tell you how many characters are in this string. -- Bill Cheng // bill.cheng@usc.edu