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

Home Posts Topics Members FAQ

details in my previous Q?????

well.....i did understand your replies partially.. but what happened
to me is that when i had used the function (strtok)
from the library <cstring>...i sent it a char* beside the delimiter
"."...as the following example
char * sentence="hai.bai.rasha";
cout<<strtok(sentence,".");
then an application error in a dialog box appeared....
as i know and as i read before...the (strtok)function do recieve a
char* and a const char* as arguments.....so why that erroe did
appear??and when i tried with an array instead ,it worked fine.....
thanx
Jul 19 '05 #1
1 1111
batee5a wrote:

well.....i did understand your replies partially.. but what happened
to me is that when i had used the function (strtok)
from the library <cstring>...i sent it a char* beside the delimiter
"."...as the following example
char * sentence="hai.bai.rasha";
cout<<strtok(sentence,".");
This produces undefined behavior because string literals are
non-mutable, and std::strtok attempts to change the contents of the
string argument (it adds NUL chars).
then an application error in a dialog box appeared....
as i know and as i read before...the (strtok)function do recieve a
char* and a const char* as arguments.....so why that erroe did
appear??and when i tried with an array instead ,it worked fine.....


Using an array allows the contents to be changed:

char sentence[] = "hai.bai.rahsa";

Note, however, that subsequent calls to std::strtok on the same logical
string should be made with a null source argument:

cout << std::strtok(0, ".");

See the recent thread "string tokenizing" for variations on string
tokenizing implementations:

http://groups.google.com/groups?thre...ail.com&rnum=1

/david

--
Andre, a simple peasant, had only one thing on his mind as he crept
along the East wall: 'Andre, creep... Andre, creep... Andre, creep.'
-- unknown
Jul 19 '05 #2

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

Similar topics

3
by: Marcel | last post by:
Hello, I'm working on a search application for my website. The website contains a lot of pictures, and a search should return clickable thumbnails. No problems there. My problem started when I...
3
by: forums_mp | last post by:
After reading a few texts - nameley koeing/moo and eckel - I decided to investigating the importance of templates. Of course there's no substitute for practice so I figured I try a simple program....
4
by: Mark D. Anderson | last post by:
About a month ago Richard Cornford did an interesting analysis of a memory leak in jscript (internet explorer) when there are "circular" references between DOM objects and (real) jscript objects:...
1
by: Andy Wells | last post by:
I'm using VB.NET and I have an application that binds a schema to the main form's controls, and the user has the ability to load an XML file through the schema and into the bound form. My...
1
by: Skip | last post by:
Hi, I created a COM object in C# and everything works fine on my machine. Now, the compiler gives me the following messages when compiling my code: ------ Rebuild All started: Project: SI,...
11
by: Prince of Code | last post by:
Hey There, I have been to this group for a couple of days. I am really impressed by the way people respond. I get answers for all my doubts and that too more info. So I am putting across a doubt...
4
by: rossum | last post by:
I am looking for a source for the internal details of the System.Random pseudo random number generator. Something reasonably technical please, not how to use it (which I know) but more how does...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
4
by: randy.buchholz | last post by:
Been fighting this one for a while, looking for help. I have a simple page with a grid view and details view (just managing a single table). The details view is primarily used for creating new...
25
by: DanicaDear | last post by:
Hello again Bytes...I missed you! First, background: In a hotstick lab, we ship orders every two years. We ship a new order and the customer uses the new box to return the previous year's order....
0
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,...
0
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
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,...
0
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...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.