473,378 Members | 1,321 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Please help me while dereferencing a pointer array

Hi,
I am having the following block of code. Should I use a NULL checking for tokens[i], where ever there is *tokens[i]. Please let me know soon.

while( !infile.eof() )
{
DmgString lineStr;

char str[500];
infile.getline (str, 499 );
lineStr = str;

if( lineStr.IsBlank() == dmgYES )
{
continue;
}
else
{
lineStr.NoSpaces();
lineStr.ToUpper();

DmgPtrList<DmgString> tokens;
lineStr.Tok(',',tokens);

if ( tokens[0] != NULL )
{
int i = 0;

if ( strcmp( (const char*)*tokens[i],
(const char*) "TRADETYPE" ) == 0 )
{
for ( i = 1; i<tokens.entries(); i++ )
{
tradeTypeList.insert( new DmgString ( *tokens[i] ) );
}
}
else if ( strcmp(
(const char*)*tokens[i], "DOCFUNCTION" ) == 0 )
{
for ( i = 1; i<tokens.entries(); i++ )
{
docFunctionList.insert( new DmgString ( *tokens[i] ) );
}
}
}
}
}



Thanks in advance.
Aug 6 '07 #1
3 1416
weaknessforcats
9,208 Expert Mod 8TB
Please re-post using code tags and proper indentation.

It's hard to read your code.
Aug 6 '07 #2
Here I am posting with proper indentation but I dont know what is code tag.

while( !infile.eof() )
{
DmgString lineStr;

char str[500];
infile.getline (str, 499 );
lineStr = str;

if( lineStr.IsBlank() == dmgYES )
{
continue;
}
else
{
lineStr.NoSpaces();
lineStr.ToUpper();

DmgPtrList<DmgString> tokens;
lineStr.Tok(',',tokens);

if ( tokens[0] != NULL )
{
int i = 0;

if ( strcmp( (const char*)*tokens[i],
(const char*) "TRADETYPE" ) == 0 )
{
for ( i = 1; i<tokens.entries(); i++ )
{
tradeTypeList.insert( new DmgString ( *tokens[i] ) );
}
}
else if ( strcmp(
(const char*)*tokens[i], "DOCFUNCTION" ) == 0 )
{
for ( i = 1; i<tokens.entries(); i++ )
{
docFunctionList.insert( new DmgString ( *tokens[i] ) );
}
}
}
}
}
Aug 7 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
docFunctionList.insert( new DmgString ( *tokens[i] ) );
}
}
}
}
}
is not indented.

The code tags are shown iun the Reply Guildlines that's just to the right of the posting window. You are probably losing the indentation due to no code tags.

[ code = cpp ]

code goes here

[ /code ]

The actual code tags are like the ones above without the embedded spaces.
Aug 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

51
by: BigMan | last post by:
Does the C++ standard define what should happen in case of NULL pointer dereferencing. If not, does it say that it is illegal? Where, if so, does it say it?
6
by: berthelot samuel | last post by:
Hi everyone, This really is a tricky one ! (at least for me:). Actually I haven't found any solution to this problem anywhere... So I'll try to be as clear as possible in my explanations. First,...
4
by: Pushkar Pradhan | last post by:
I have some functions which take as i/p a buffer (it can be float, char, or 16 bit, int etc.). The result is another o/p buffer, its type is also flexible (it could be a float, char etc.). I try...
28
by: Martin Jørgensen | last post by:
Hi, I have a "funny" question, which I think is pretty "healthy" to examine... This program is being investigated: - - - - - - - #include <iostream> using namespace std; #define DAYS 7
9
by: incredible | last post by:
how to sort link list of string
11
by: food4uk | last post by:
Dear all : I am not good at programming, please give a hand. My data structure is very similar as an array. I actually can use the std::vector as container to organize my data objects. However,...
1
by: David Mathog | last post by:
We've established that a line of code like: (void) function( (long *) &(something) ); may (and probably should) generate one of these warning: dereferencing type-punned pointer will break...
8
by: sachinv1821 | last post by:
hi all i have simple Problem please tell me the Solution if u know?? main() { int a={1,2,3,4,5,6,7,8,9}; printf("%u %u %u",a,a,a); } when i execute this program i am getting a Fixed address...
20
by: prashant.khade1623 | last post by:
I am not getting the exact idea. Can you please explain me with an example. Thanks
12
by: viza | last post by:
Hi I have program1.c: typedef int (*fn_t)(int); int fn( int f ){ return f; }
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.