This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Is this code valid under g++
- From: "Ajay Bansal" <Ajay_Bansal at infosys dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Thu, 20 Mar 2003 14:31:03 +0530
- Subject: Is this code valid under g++
Is the following code corect??
char*
getNextItem(char* line, const char* delimit)
{
// Retrieve the next item, and strip off any whitespace around it
char* item;
char* tmp;
item = strtok(line, delimit);
if (item)
{
// Strip off leading whitespace
while (*item == ' ' || *item == ' ')
{
item++;
} // while
// Find any trailing spaces, tabs, newlines
tmp = strpbrk(item, " \t\n");
if (tmp)
{
*tmp = '\0';
} // if
// Comment, or end of line
if (*item == '#' || *item == '\n' || *item == '\0')
{
// Return as if nothing
item = 0;
} // if
} // if
return item;
} // getNextItem()
CAN WE RETURN item (it is local to the function)