473,486 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

delete an alphabet

4 New Member
#

Write a function named deleteS that accepts one character pointer as a parameter and returns no value. The parameter is a C string. This function must remove all of the upper and lower case 's' letters from the string. The resulting string must be a valid C string.

Your function must declare no more than one local variable in addition to the parameter; that additional variable must be of a pointer type. Your function may not use any square brackets.

int main()
{
char msg[50] = "She'll be a massless princess.";
deleteS(msg);
cout << msg; // prints he'll be a male prince.
}


Can anyone give me some hints on this? Thx

this is how my function gonna look like.. I think...
void deleteS(const char* str, char alpha)

and alpha is gonna be S or s
Nov 28 '06 #1
3 1957
xx1level1xx
4 New Member
ooop it should be void deleteS(char* str)
Nov 28 '06 #2
xx1level1xx
4 New Member
I m a neophyte and this is my nonworking code:


[void deleteS(char *str)
{
char* source= str;

while(*source!=0)
{
*source=*str;
if (str!="S" ||str!="s")
{

source++;
str++;
}
else if (str=="S"|| str== "s")
{
str++;
}
}
}
Nov 28 '06 #3
sivadhas2006
142 New Member
Hi,

You can also do like this.

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. void deleteS(char * a_pszInput, char *a_pszOutput)
  7. {
  8.    char
  9.       chTemp = '\0';;
  10.  
  11.    while(*a_pszInput !=0) 
  12.    {      
  13.       chTemp = *a_pszInput;
  14.       if (chTemp != 'S' && chTemp!= 's')
  15.       { 
  16.          *a_pszOutput = *a_pszInput;
  17.          a_pszOutput++;
  18.       }
  19.       a_pszInput++;
  20.    }
  21. }
  22.  
  23.  
  24. int main()
  25. {
  26.    char 
  27.       szMsg[50] = "She'll be a massless princess.",
  28.       szResult[50] = "\0";
  29.  
  30.    deleteS(szMsg, szResult);
  31.    cout << szResult; // prints he'll be a male prince.
  32.    return 0;
  33. }
  34.  
Regards,
M.Sivadhas.
Nov 28 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
6630
by: Stefan Krah | last post by:
Hello, I am currently writing code where it is convenient to convert char to int . The conversion function relies on a character set with contiguous alphabets. int set_mesg(Key *key, char...
12
14490
by: one | last post by:
greetings i am just wondering if some expert here can either show me how to do this or point me to the right direction (url... i want to use c# to generate a list of alphabet e.g A B C ... AA...
8
3233
by: Jack Addington | last post by:
I want to scroll through the alphabet in order to scroll some data to the closest name that starts with a letter. If the user hits the H button then it should scroll to the letter closest to H. ...
9
11197
by: booksnore | last post by:
I am writing some code to search for strings that contain every letter of the alphabet. At the moment I am using the method below to check to see if a string contains every letter of the alphabet....
31
2623
by: Joe Smith | last post by:
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789" " " "!#%^&*()-_" "+=~\|;:\'" "\"{},.<>/\?" "\a\b\f\n\r\t\v\\" Do the above string literals comprise an alphabet for C?...
0
2957
by: rockdale | last post by:
Hi, all: I implemented an alphabet list so that when user click letter A then I will re-bind a gridview control using SQL stored procedure. It works fine. The problem is I populate my alphabet...
1
1761
by: kannabiran | last post by:
Hi, Im using C# ASP.Net here in the textbox i need to get the input as like follows ,any alphabet or any alphabet,any alphabet for example ,C or C,E like this i want to get the input.The...
12
2957
by: paitoon | last post by:
Hi, I got a little bit problem about search result in my site. When i put the keyword and click on search ....everything work fine i got the correct result but they not order by the keyword,but...
20
18994
by: geebanga88 | last post by:
HI i have a method that is supose to store the alphabet in an array however dont think that it is being added to the array. public static void GetAlphabet (char alphabet) { int...
3
3067
by: sivadhanekula | last post by:
Hi all I am working on excel, Macros with vb6....When I was writing the for loop I got stuck with getting the next alphabet...Like I need to extract the data from a database and I need to split...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7319
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.