473,612 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
+ 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 1967
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
6647
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 *s) { char *x;
12
14569
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 AB AC AD ... AAB ... ZZZZY ... ZZZZ any suggestion will be greatly appreciated thank you
8
3253
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. If no one exists with H, then go to I, etc. If its near the end, say 'V', and the last person is a 'T' then it should work its way back up the alphabet. I was trying to loop as if the Char's were ints but I am having problems I have buttons...
9
11217
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. I wanted to use a regular expression but I could not find an ‘AND’ operator within the regular expression – so I need something like match true if string contains ‘a’ and ‘b’ and ‘c’ and ‘d’ ..etc,etc. If anyone has any thoughts on how I can...
31
2652
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? joe
0
2964
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 repeater by select the ini of name from database. So that my alphabet does not have 26 letters, my customer does not like it since it may spell something bad. Now I am trying to display 26 letters, letters that exist in my database will be...
1
1767
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 textbox should get only one comma and it should not get any other special characters.it can be either by server side code or by the java script code..How should i do this any assistance plz.. rgrds
12
2972
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 they order by the alphabet.....some and the problem is happen sure if there are many result to display...the real result that people put keyword for will be in the last page...because the computer order by the alphabet. for example...i put the keyword...
20
19019
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 index, ordinalVal = 97; char element; for (index = 1; index < alphabet.length; ++index, ++ordinalVal) { element = (char) ordinalVal;
3
3075
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 that data in to equal parts and each part should go to diff column in the excel sheet like A, B, C, D.....Z if you look at the code in the code if you look at the Bold letters...and when the loop is running I need the Next alphabet in the place...
0
8162
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8605
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8565
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8246
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8415
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6076
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4045
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4109
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.