unsaon pag identify and count sa special characters within an inputted string
![]()
Hope this can help. Cprogramming.com - C++ Standard Library - String Class
the TS asking about C string.. which is different if dealing with C++ strings
@MarkCuerting => Why don't you give him what he wants because I think you know a lot more than I do. As I posted, Don't you understand the meaning of this? "Hope this can help" Or you are just here to look what you think is mistake of other people.
Last edited by johnsital; 07-20-2010 at 02:33 PM. Reason: Update...
use string.h and use strlen() function:
ex:
{
int x;
char name[30] = 'MARK';
x=strlen(name);
printf("Character count = %d",x);
}
//mao na xa...try it!!
I don't if the TS will come back soon LOL...
That is only to determine the length of the string.
Inorder to solve the 2nd problem, regarding, how many special characters in a string:
void main()
{
int x;
int count;
char name[30] = "b@r3f00t!";
x=strlen(name);
printf("Character count = %d",x);
for(i=0; i<x; i++)
if(!isalnum(name[i]))
count++;
printf("\nNumber of Special Characters: %d", count);
getch();
}
- dugay2 nako wala magprogram ug C (nya diretso ra pud ko reply diri) so basin naa ko sayup ani...pero try lang na ug padagan....
daghang salamat sa nag post! bro b@refoot!!salamat kayo..
maau dyud ni si b@r3f00t da.... saludo ko nmo bro...
Similar Threads |
|