--- On Fri, 11/21/08, Olufowobi Lawal <[EMAIL PROTECTED]> wrote:

From: Olufowobi Lawal <[EMAIL PROTECTED]>
Subject: [c-prog] ascii space problem?That new guy!
To: "c group2" <[email protected]>
Date: Friday, November 21, 2008, 4:56 PM

//This program removes a space from a string.

#include<stdio. h>
#include <STRING.H>
main()
{
char w[50];
int i;
scanf("%s",& w);

for(i=0;i<strlen( w);i++)
{
if(w[i]==65)
continue;
printf("%c", w[i]);
}

}

for an input: dAd
output dd, as expected

when changed to if(w==32)
32 asci for space

for an input:d d
output is d

why is this so?

I also tried using if(w=='') but i got the same result.

any ideas on how to implement this? Or where I'm gettin it wrong.


The problem is the scanf implimentation. When the scanf encounters the
space character it signals end of string. So the only character read is 'd'. 

Regards,
Mickey M.
Construction Partner Inc.
http://www.constructionpartner.com



      

[Non-text portions of this message have been removed]

Reply via email to