how to trim Spaces from unsigned char*
-
hi friends, unsigned char Cstr[100] = "this is a program"; i want remove spaces from Cstr; please help any body
-
hi friends, unsigned char Cstr[100] = "this is a program"; i want remove spaces from Cstr; please help any body
Member 3653751 wrote:
i want remove spaces from Cstr;
So what trouble(s) are you having in doing so?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
-
hi friends, unsigned char Cstr[100] = "this is a program"; i want remove spaces from Cstr; please help any body
copy the string char by char and skip the spaces.
Watched code never compiles.
-
copy the string char by char and skip the spaces.
Watched code never compiles.
unsigned char pChar[100] = "i like vc++! "; printf("%s\n%s",pChar); it will compile and run..but it displaying 100 characters... 100 character means i like vc++ after null please help me any body
-
unsigned char pChar[100] = "i like vc++! "; printf("%s\n%s",pChar); it will compile and run..but it displaying 100 characters... 100 character means i like vc++ after null please help me any body
Member 3653751 wrote:
printf("%s\n%s",pChar);
When your format string has two
%s
specifiers, you must have two parameters after the format string. So add one parameter toprintf()
or remove one%s
from format string.modified on Tuesday, May 4, 2010 11:35 AM
-
unsigned char pChar[100] = "i like vc++! "; printf("%s\n%s",pChar); it will compile and run..but it displaying 100 characters... 100 character means i like vc++ after null please help me any body
nothing here shows you are "trimming" the string; and there's an extra "%s" in the format part of printf.
Watched code never compiles.
-
unsigned char pChar[100] = "i like vc++! "; printf("%s\n%s",pChar); it will compile and run..but it displaying 100 characters... 100 character means i like vc++ after null please help me any body
Member 3653751 wrote:
unsigned char pChar[100] = "i like vc++! "; printf("%s\n%s",pChar);
Member 3653751 wrote:
it will compile and run..but it displaying 100 characters...
Because
Visual C++
doesn't like you. :rolleyes:If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
copy the string char by char and skip the spaces.
Watched code never compiles.
Hi. This litte program copys the string char by char and skips the spaces.
#include <iostream.h>
int count=0,count2=0;
int strLength=0;int main()
{
unsigned char Cstr[100] = "this is a program";
unsigned char Cstr2[100] = "";while(Cstr\[count\] != '\\0') { if((int)Cstr\[count\] !=32) { Cstr2\[count2 \] = Cstr\[count\]; count2++; } count++; strLength++; } for(count=0;count<strLength;count++) cout<<Cstr2\[count\]<<""; cout<<"\\n\\n\\n"; return 0;
}
-
hi friends, unsigned char Cstr[100] = "this is a program"; i want remove spaces from Cstr; please help any body
unsigned char Cstr[100] = "this is a program"; unsigned char CstrS[100]; for (int i = 0, i2 = 0; i < 100; i++) { if (Cstr[i] != ' ') { CstrS[i2] = Cstr[i]; i2++; } else continue; }