473,796 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

default strtok behaviour

Hi,
what would be the default strtok behaviour when a null string is passed
into the string parameter in the first call to strtok?
I would expect a null pointer to be returned but it is sometimes causing my
program to crash.
Thanks.

Feb 13 '07 #1
2 1096

"sven" <sv**@discussio ns.microsoft.co mwrote in message
news:AD******** *************** ***********@mic rosoft.com...
Hi,
what would be the default strtok behaviour when a null string is passed
into the string parameter in the first call to strtok?
I would expect a null pointer to be returned but it is sometimes causing
my
program to crash.
By "null string", do you mean null pointer, or empty (zero-length
NUL-terminated) string?
Thanks.

Feb 13 '07 #2
Sorry for the ambuguity. I mean the null pointer.
This null pointer is returned from a failed previous api call but it does
not cause the app to crash everytime it reaches strtok.

"Ben Voigt" wrote:
>
"sven" <sv**@discussio ns.microsoft.co mwrote in message
news:AD******** *************** ***********@mic rosoft.com...
Hi,
what would be the default strtok behaviour when a null string is passed
into the string parameter in the first call to strtok?
I would expect a null pointer to be returned but it is sometimes causing
my
program to crash.

By "null string", do you mean null pointer, or empty (zero-length
NUL-terminated) string?
Thanks.


Feb 14 '07 #3

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

Similar topics

13
4927
by: ern | last post by:
I'm using strtok( ) to capture lines of input. After I call "splitCommand", I call strtok( ) again to get the next line. Strtok( ) returns NULL (but there is more in the file...). That didn't happen before 'splitCommands' entered the picture. The problem is in splitCommands( ) somehow modifying the pointer, but I HAVE to call that function. Is there a way to make a copy of it or something ? /* HERE IS MY CODE */ char *...
8
2246
by: manochavishal | last post by:
Hi I am writing a Program in which i get input as #C1012,S,A#C1013,S,U I want to get C1012,S,A using strtok and then pass this to function CreateVideo which will further strtok this (C1012,S,A) and store the required values.
2
2090
by: manochavishal | last post by:
Hi I am writing a Program in which i get input as #C1012,S,A#C1013,S,U I want to get C1012,S,A using strtok and then pass this to function CreateCopies which will further strtok this (C1012,S,A) and store the required
5
7711
by: plmanikandan | last post by:
Hi, I need to split the value stored in a string and store them to another charrecter array.I am using strtok function.But i am getting invalid output when there is no value between delimiter my code #include<stdio.h> #include<string.h> #include<stdlib.h> void main()
17
5212
by: bofh1234 | last post by:
I need to delimit a string. The delimiters are a semicolon and comma. When I run the program I get a segmentation fault on the first strtok. I followed the examples of others and from my old C books, but I can't seem to find the problem. The accesslist has a format of 20,45;22,44;46,28;99,43,etc. What am I doing wrong? Thanks, #include <sys/signal.h> #include <messages.h>
8
1932
by: hu | last post by:
hi, everybody! I'm testing the fuction of strtok(). The environment is WinXP, VC++6.0. Program is simple, but mistake is confusing. First, the below code can get right outcome:"ello world, hello dreams." #include <stdafx.h> #include <string.h> #include <stdio.h> int main()
18
3498
by: Robbie Hatley | last post by:
A couple of days ago I dedecided to force myself to really learn exactly what "strtok" does, and how to use it. I figured I'd just look it up in some book and that would be that. I figured wrong! Firstly, Bjarne Stroustrup's "The C++ Programming Language" said: (nothing)
3
2515
by: adolghiu | last post by:
Hi, I have a text file as input which has odd chars like: - // " Bellow is a sample: Jul 6 00:00:13 proxyhost httpd: 172.26.74.212 - "GET http://www.google.com/gwt/i?i=08 9E3394C_C235D1FF_FA6C3045 HTTP/1.1" 200 200 383 78881e-1 N COMPLETE 158 REQ:220:0:130:4:100:0:10:8:30:0:60:0:5:0:200:0 EXE:80:0:125:0:15:0:230:0 MOD :240:0:210:0:90:0:110:0:20:0 RES:40:0:70:30:120:0:260:0 PD:126:0 113 - 1 I read the file line by line and split it...
75
25142
by: siddhu | last post by:
Dear experts, As I know strtok_r is re-entrant version of strtok. strtok_r() is called with s1(lets say) as its first parameter. Remaining tokens from s1 are obtained by calling strtok_r() with a null pointer for the first parameter. My confusion is that this behavior is same as strtok. So I assume strtok_r must also be using any function static variable to keep the information about s1. If this is the case then how strtok_r is re-...
0
9680
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
9528
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
10230
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
10174
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
10012
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...
0
6788
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();...
0
5442
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
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.