Return-Path: william@bourbon.usc.edu Delivery-Date: Mon Sep 8 23:14:19 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 m896EJJW032365 for ; Mon, 8 Sep 2008 23:14:19 -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 m896DSEr017028 for ; Mon, 8 Sep 2008 23:13:28 -0700 Message-Id: <200809090613.m896DSEr017028@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: regarding ASCII part Date: Mon, 08 Sep 2008 23:13:28 -0700 From: Bill Cheng Someone wrote: > I have allocated sizeof DataLen and doin memset and memcpy of DataLen. > i have also checked the data I receive .However when I > print response.Data i m getting special charaters > (as it is not Null terminated).  > How are we supposed to print response.Data? ( can we use snprintf) If you want to use printf(), you can allocate a buffer that's one byte longer than DataLength, copy the data into this buffer, and add a trailing '\0'. -- Bill Cheng // bill.cheng@usc.edu ----- Original Message ---- From: Bill Cheng To: cs551@merlot.usc.edu Sent: Monday, September 8, 2008 10:27:58 PM Subject: Re: regarding ASCII part Someone wrote:   > I am little confused between ascii string uses part.   > Suppose I am sending a string of 3 chars from server to client for e.g.   > "abc". I received 3 chars in response.Data field. Can I put '\0' as 4th   > character in response.Data field for printing purpose? Is it okey if I   > allocate +1 memory than response.DataLen for this purpose? That would violate the spec!  Right?! -- Bill Cheng // bill.cheng@usc.edu