473,803 Members | 2,937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does strtok require a non-null token?

I'm using strtok to break apart a colon-delimited string. It basically
works, but it looks like strtok skips over empty sections. In other
words, if the string has 2 colons in a row, it doesn't treat that as a
null token, it just treats the 2 colons as a single delimiter.

Is that the intended behavior?

Oct 12 '06
26 4426
On 16 Oct 2006 16:53:37 -0700, "William Hughes"
<wp*******@hotm ail.comwrote:
>
Al Balmer wrote:
>On 12 Oct 2006 20:42:00 -0700, "William Hughes"
<wp*******@hot mail.comwrote:
>In any case, I don't think your average maintainence drone would
know how strtok() works,

Huh! I resent that ;-)

My appologies for an unintended insult.
>>
This maintenance drone has known about strtok for many years, as well
as all the other functions in the standard library. "Maintenanc e
drones" not only need to be capable of writing good, solid,
maintainable code, but have the added burden of needing to figure out
what some cowboy coder really meant to do.


I agree. Maintenance is difficult work and the best programmers
should be placed on maintenance, not new development.
In my experience, however, this is not the case. The term
"Maintenanc e drone" is all too often appropriate.
You may well be correct. Although I've worked for large companies,
their product focus was never software, and I often worked alone, so
I'm in no position to know how qualified an average maintenance
programmer is. I can relate my experience that many programmers who
consider themselves too good for maintenance work are incompetent,
though :-)

(I worked for one very small company where the entire programming
staff was top-notch - my own <g>)

--
Al Balmer
Sun City, AZ
Oct 17 '06 #21

Al Balmer wrote:
On 16 Oct 2006 16:53:37 -0700, "William Hughes"
<wp*******@hotm ail.comwrote:

Al Balmer wrote:
On 12 Oct 2006 20:42:00 -0700, "William Hughes"
<wp*******@hotm ail.comwrote:

In any case, I don't think your average maintainence drone would
know how strtok() works,

Huh! I resent that ;-)
My appologies for an unintended insult.
>
This maintenance drone has known about strtok for many years, as well
as all the other functions in the standard library. "Maintenanc e
drones" not only need to be capable of writing good, solid,
maintainable code, but have the added burden of needing to figure out
what some cowboy coder really meant to do.

I agree. Maintenance is difficult work and the best programmers
should be placed on maintenance, not new development.
In my experience, however, this is not the case. The term
"Maintenanc e drone" is all too often appropriate.
You may well be correct. Although I've worked for large companies,
their product focus was never software, and I often worked alone, so
I'm in no position to know how qualified an average maintenance
programmer is. I can relate my experience that many programmers who
consider themselves too good for maintenance work are incompetent,
though :-)

Which touches on an important point. New development is more
fun than maintenance (at least this seems to be a fairly widely held
opinion). Now, as a manager you decide that your are going to
put the best programmers on maintenance. You do this, all your
best programmers leave, you get fired.

- William Hughes

Oct 17 '06 #22
in 701714 20061017 183648 "William Hughes" <wp*******@hotm ail.comwrote:
>You may well be correct. Although I've worked for large companies,
their product focus was never software, and I often worked alone, so
I'm in no position to know how qualified an average maintenance
programmer is. I can relate my experience that many programmers who
consider themselves too good for maintenance work are incompetent,
though :-)


Which touches on an important point. New development is more
fun than maintenance (at least this seems to be a fairly widely held
opinion). Now, as a manager you decide that your are going to
put the best programmers on maintenance. You do this, all your
best programmers leave, you get fired.
In my experience the maintenance guys are the real heroes.
The developers quickly knock off something which roughly corresponds to
the original spec then move on.
The maintenance people then get all the bugs out, change it to what was really
required then add all the nice features.
Oct 18 '06 #23
Which touches on an important point. New development is more
fun than maintenance (at least this seems to be a fairly widely held
opinion). Now, as a manager you decide that your are going to
put the best programmers on maintenance. You do this, all your
best programmers leave, you get fired.
That is the reality...(up to my limited knowledge.)
In someone's Signature in comp.lang.c i have seen,

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."

Derivation From the above stmt.

"If you are doing debugging/Maintance of software you are more clever
than devloper, most probably your senior :)"
Actually Wrong Thinking here, for detailed discussion there is a thread
on
comp.software-eng named "most software jobs are software maintenance
rather than new development?" and i think some Interesting Thoughts are
there.

In my experience the maintenance guys are the real heroes.
The developers quickly knock off something which roughly corresponds to
the original spec then move on.
The maintenance people then get all the bugs out, change it to what was really
required then add all the nice features.

Have To Agree...
Sorry for giving reply on Not "C lang" related answer,
Cheers
--Raxit

Oct 18 '06 #24
"William Hughes" <wp*******@hotm ail.comwrote:
Al Balmer wrote:
You may well be correct. Although I've worked for large companies,
their product focus was never software, and I often worked alone, so
I'm in no position to know how qualified an average maintenance
programmer is. I can relate my experience that many programmers who
consider themselves too good for maintenance work are incompetent,
though :-)

Which touches on an important point. New development is more
fun than maintenance (at least this seems to be a fairly widely held
opinion). Now, as a manager you decide that your are going to
put the best programmers on maintenance. You do this, all your
best programmers leave, you get fired.
IMO, the best thing (but probably equally infeasible) would be not to
have maintenance or development programmers, but project programmers.
You developed it, you maintain it.

Richard
Oct 18 '06 #25

Richard Bos wrote:
"William Hughes" <wp*******@hotm ail.comwrote:
Al Balmer wrote:
You may well be correct. Although I've worked for large companies,
their product focus was never software, and I often worked alone, so
I'm in no position to know how qualified an average maintenance
programmer is. I can relate my experience that many programmers who
consider themselves too good for maintenance work are incompetent,
though :-)
Which touches on an important point. New development is more
fun than maintenance (at least this seems to be a fairly widely held
opinion). Now, as a manager you decide that your are going to
put the best programmers on maintenance. You do this, all your
best programmers leave, you get fired.

IMO, the best thing (but probably equally infeasible) would be not to
have maintenance or development programmers, but project programmers.
You developed it, you maintain it.
Two problems:

- the lifetime of many (most?) projects is longer that the
time a programmer spends with the company.

-if there is more than one person on the project the
maintenance will be done by the more junior
(an edict that maintenance work is to be distributed
in any other way could only come from a soon to be
fired member of senior management)

- William Hughes

Oct 18 '06 #26
av
On 18 Oct 2006 00:29:20 -0700, ra************@ yahoo.co.in wrote:
>"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
yes, but for debug can be enought some routines that find errors
*time* and luck :)
Oct 27 '06 #27

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

Similar topics

12
1840
by: ern | last post by:
I'm using it like this: char * _command = "one two three four"; char * g_UserCommands; const char * delimeters = " "; g_UserCommands = strtok(_command, delimeters); g_UserCommands = strtok(g_UserCommands, delimeters); g_UserCommands = strtok(g_UserCommands, delimeters); g_UserCommands = strtok(g_UserCommands, delimeters); //Then I print each entry of g_UserCommands.
7
5711
by: Fernando Barsoba | last post by:
Hi, I'm using strtok() in the following way: void obtain_param(char *pmsg, CONF_PARAMS *cnf ) { char *s1, *s2; size_t msg_len; s1 = strtok (pmsg,":"); if (s1) {
7
4368
by: Peter | last post by:
hi all, the strtok() cannot phrase the token within another token, am i correct? For example, i want to get the second word of every row of a file, how to use strok to complete this? thanks from Peter (cmk128@hotmail.com)
5
7716
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()
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()
4
2736
by: Michael | last post by:
Hi, I have a proble I don't understand when using strtok(). It seems that if I make a call to strtok(), then make a call to another function that also makes use of strtok(), the original call is somehow confused or upset. I have the following code, which I am using to tokenise some input which is in th form x:y:1.2: int tokenize_input(Sale *sale, char *string){
14
3327
by: Mr John FO Evans | last post by:
I cam across an interesting limitation to the use of strtok. I have two strings on which I want strtok to operate. However since strtok has only one memory of the residual string I must complete one set of operations before starting on the second. This is inconvenient in the context of my program! So far the only solution I can see is to write a replacement for strtok to use on one of the strings. Can anyone offer an alternative?
29
2591
by: Pietro Cerutti | last post by:
Hello, here I have a strange problem with a real simple strtok example. The program is as follows: ### BEGIN STRTOK ### #include <string.h> #include <stdio.h>
3
2173
by: semi_evil | last post by:
I downloaded a few PHP scripts from various sites, in part to use them as is, and partly to study and learn from them. One script is littered with strtok() occurrences. So I checked the manual for its details. I do understand the basics of it, and the limitations (like not being able to work on two strings simultaneously for loss of the strtok internal 'pointer'). And it MUST be my ignorance and/or limited experience, but I don't
75
25146
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
9566
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
10317
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...
0
9127
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7607
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
6844
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
5503
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
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
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
3
2974
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.