473,804 Members | 3,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert a string into a string

Is there a special function to insert a string into another string ?
For example I want to exchange the german "Umlauts" ä,ö,ü with ae,oe
and ue in a string.
I also wonder if there is a function to get the alphabet of a string ?
Do two strings share the same alphabet ?

P.S.: What book can you recommand your C and/or C++ ? Don´t say
Kernighan & Ritchie. Should be useful not only to learn but also to
look up things.

Thanks a lot
Jun 27 '08 #1
7 2553
Ha************* ***@web.de wrote:
Is there a special function to insert a string into another string ?
For example I want to exchange the german "Umlauts" ä,ö,ü with ae,oe
and ue in a string.
No, but there are [1] functions like strchr() and strcspn()
that can help you find the ä,ö,ü,... in the original string,
[2] functions like malloc() and realloc() to allocate memory
for the longer result string, and [3] functions like strcpy(),
strcat(), memcpy(), and memmove() to copy strings or string
segments from one place to another.
I also wonder if there is a function to get the alphabet of a string ?
Do two strings share the same alphabet ?
No, but you can do this for yourself easily enough. If
all you care about is the set of characters from which the
string is formed (rather than, say, the count of how many
times each character appears), you could do something like

unsigned char alphabet[1+UCHAR_MAX];
memset (alphabet, 0, sizeof alphabet);
for (ptr = theString; *ptr != '\0'; ++ptr)
alphabet[ (unsigned char)*ptr ] = 1;

.... after which the array alphabet[] will contain a 1 in each
position that corresponds to a character in the string, and a
0 for each character that is not present. To compare the
alphabets of two strings, use memcmp() on their arrays.

Note that this technique assumes one "character" is one
char, one byte. If multi-byte encodings are a concern you
will need to work harder.
P.S.: What book can you recommand your C and/or C++ ?
Kernighan and Ritchie.
Don´t say
Kernighan & Ritchie.
Oops! Sorry; it just slipped out.
Should be useful not only to learn but also to
look up things.
--
Eric Sosman
es*****@ieee-dot-org.invalid
Jun 27 '08 #2
Ha************* ***@web.de wrote:

<snip>
P.S.: What book can you recommand your C and/or C++ ? Don´t say
Kernighan & Ritchie. Should be useful not only to learn but also to
look up things.
Then I recommend /C: A Reference Manual/ by Harbison and Steele.
<http://careferencemanu al.com/>

and /The Standard C Library/ by P. J. Plauger.
<http://portal.acm.org/citation.cfm?id =532092>

Jun 27 '08 #3
santosh <sa*********@gm ail.comwrites:
Ha************* ***@web.de wrote:

<snip>
>P.S.: What book can you recommand your C and/or C++ ? Don´t say
Kernighan & Ritchie. Should be useful not only to learn but also to
look up things.

Then I recommend /C: A Reference Manual/ by Harbison and Steele.
<http://careferencemanu al.com/>

and /The Standard C Library/ by P. J. Plauger.
<http://portal.acm.org/citation.cfm?id =532092>
I would heartily NOT recommend the Standard C Library for a new
programmer to C. It is more of a reference for when you understand how
to program in C IMO.
Jun 27 '08 #4
Richard wrote:
santosh <sa*********@gm ail.comwrites:
>Ha************* ***@web.de wrote:

<snip>
>>P.S.: What book can you recommand your C and/or C++ ? Don´t say
Kernighan & Ritchie. Should be useful not only to learn but also to
look up things.

Then I recommend /C: A Reference Manual/ by Harbison and Steele.
<http://careferencemanu al.com/>

and /The Standard C Library/ by P. J. Plauger.
<http://portal.acm.org/citation.cfm?id =532092>

I would heartily NOT recommend the Standard C Library for a new
programmer to C. It is more of a reference for when you understand how
to program in C IMO.
The OP seems to want something that he can use as a tutorial *and* as a
reference. K&R2 is actually very suitable for this purpose (barring the
fact that's for C90), but he explicitly said he doesn't want it to be
recommended.

As an alternative he might try /C Primer Plus/ by Stephen Prata.
<http://safari.oreilly. com/0672326965>

It's a good book for learning C and also contains a small reference
section as an appendix.

Jun 27 '08 #5
santosh <sa*********@gm ail.comwrites:
Richard wrote:
>santosh <sa*********@gm ail.comwrites:
>>Ha************* ***@web.de wrote:

<snip>

P.S.: What book can you recommand your C and/or C++ ? Don´t say
Kernighan & Ritchie. Should be useful not only to learn but also to
look up things.

Then I recommend /C: A Reference Manual/ by Harbison and Steele.
<http://careferencemanu al.com/>

and /The Standard C Library/ by P. J. Plauger.
<http://portal.acm.org/citation.cfm?id =532092>

I would heartily NOT recommend the Standard C Library for a new
programmer to C. It is more of a reference for when you understand how
to program in C IMO.

The OP seems to want something that he can use as a tutorial *and* as a
reference. K&R2 is actually very suitable for this purpose (barring the
fact that's for C90), but he explicitly said he doesn't want it to be
recommended.
It's the best programming tutorial for beginners I have ever read bar
none.
>
As an alternative he might try /C Primer Plus/ by Stephen Prata.
<http://safari.oreilly. com/0672326965>

It's a good book for learning C and also contains a small reference
section as an appendix.
Agreed.
Jun 27 '08 #6
Ha************* ***@web.de wrote:

P.S.: What book can you recommand your C and/or C++ ? D
First, pick a language. The answers you get (and the newsgroup you
should be using) will vary.


Brian
Jun 27 '08 #7
Ha************* ***@web.de writes:
Is there a special function to insert a string into another string ?
For example I want to exchange the german "Umlauts" ä,ö,ü with ae,oe
and ue in a string.
I also wonder if there is a function to get the alphabet of a string ?
Do two strings share the same alphabet ?
What do you mean by "the alphabet of a string"?
P.S.: What book can you recommand your C and/or C++ ? Don't say
Kernighan & Ritchie. Should be useful not only to learn but also to
look up things.
There is no book I'd recommend for C and/or C++. There are books I'd
recommend for C, and books I'd recommend for C++.

For C, I recommend Kernighan & Ritchie. Knowing why you don't want us
to mention it (it's widely considered the best book on C, and one of
the best books on programming) might help us offer more suitable
advice about other books. Harbison & Steele's "C: A Reference
Manual", 5th Edition, is a good reference. The standard is the
definitive reference, but it may not be what you're looking for.

For C++, ask in comp.lang.c++ -- but first check the C++ FAQ.

--
Keith Thompson (The_Other_Keit h) <ks***@mib.or g>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2527
by: Howard Hinnant | last post by:
I recently asked for a survey of multimap insert with hint behavior, in support of a paper I'm writing concerning lwg issue 233. My sincere thanks to Beman Dawes, Raoul Gough, Russell Hind, Bronek Kozicki, Nicola Musatti, John Potter and Maxim Yegorushkin for helping with that survey. Since I started work on this paper at least two people I respect very much have expressed interest in nailing down the "insert without hint" function a...
7
14796
by: tano | last post by:
Hello, I have to insert a char in the middle of a string, I have written two functions but I don't know what is the better? The problem is: if I use malloc() I copy all the string with the new char in the middle every time, with realloc() the part of the string before the position where the char has to be inserted is not changed if realloc returns the same pointer is passed, but if not the string is copied at all the first time, and then...
7
6680
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double checked, and the insert works fine (tried to use it from access)... im using visual C# express 2k5... what could be wrong? thanks!
11
23039
by: Chris Fink | last post by:
I have setup an Oracle table which contains a blob field. How do I insert data into this field using C# and ADO.net?
20
5661
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just client-side HTML, CSS, etc. What I want to do is somehow insert a *server control* into the , then set the server control's properties at runtime.
3
3453
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all the necessary records in it when testing it. I get the error "No value given for one or more required parameters." when I try to update the database. Can you tell me what am I doing wrong?
2
2408
by: Polyhedron_12 | last post by:
I am having problems calling functions in general in VB. I keep getting alot of errors. Can anybody help me out with this? I put the error message on the same line that it says it is at. I believe that I am not calling the function correctly. The MyInsertMethod function is the function that comes in the Web Matrix Toolbox <%@ Page Language="VB" %>
3
5165
by: mahajanvit | last post by:
Hi one and all I got this problem during my project. So in order to solve this I made a very small application. I am trying to insert using SP and sqldatasource control. I know that while using sqldatasource control, there is no need of opening and closing a connection. Also there is no need to write connection string. When i am selecting table from sqldatasource and writing insert statement in C# code, its working fine. When I am...
6
3477
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am using MS-Access 2000 database table for this app. Note that the datatype of all the fields mentioned above are Text. Apart from the above columns, there's another column in the DB table named 'RegDateTime' whose datatype is Date/Time which is...
0
2156
ak1dnar
by: ak1dnar | last post by:
There is a Error getting while i am entering records using this jsp file. <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <%@ include file="../Connections/conn.jsp" %> <% // *** Edit Operations: declare variables // set the form action variable String MM_editAction = request.getRequestURI(); if (request.getQueryString() != null && request.getQueryString().length() > 0) {
0
9706
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
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10575
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
10330
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
7616
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
6851
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4297
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
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.