Sponsored Content
Top Forums Programming Checking an array for NULL in C++ Post 302543987 by Corona688 on Tuesday 2nd of August 2011 03:33:57 PM
Old 08-02-2011
Quote:
Originally Posted by mind@work
Actually ...wt. I had to check was that if the char pointer has a string initialized or it is not yet initialized.
To check if a string is zero length is easy even without a function call.
Code:
if(str[0] == '\0')

But uninitialized doesn't mean zero length, uninitialized means undefined. That means empty only if you're lucky. If you're unlucky it could be full of garbage. Don't check if a string is uninitialized -- don't leave around uninitialized strings, period.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

compare null with non-null

I've got a very peculiar situation. I'm trying to find out if we can compare null fields with non-null. I've output csv files from SQL and Oracle. I need to compare each field from the files, and then find out any differences. The files usualy have over 500 fields, and send the resule to DBA.... (8 Replies)
Discussion started by: nitin
8 Replies

2. Shell Programming and Scripting

Checking for null value

Dear All, I'm glad that I've also joined in this forum. Good work fellas... :b: Keep going...! :) I am having a .csv file where I am reading the values with comma(,) as delimiter. After reading each and every values, I would like to check whether it is empty (say null or blank spaces). How... (4 Replies)
Discussion started by: ganapathi.t
4 Replies

3. Shell Programming and Scripting

PHP: how can I delete empty/NULL elements from a multi-dimensional array.

Hi all I have a file that i'm running and exec(cat ./dat) against..and putting its contents into any array, then doing an exploding the array into a multi-dimension array... The 15 multi-dimensional arrays have elements that are null/empty, I would like to remove/unset these elements and then... (2 Replies)
Discussion started by: zeekblack
2 Replies

4. Programming

C++ segmentation fault while checking for null pointer

void disptree(node *ptr) { if ((ptr->left) !=NULL) disptree(ptr->left); cout<<"Position:"<<ptr->pos<<" Data:"<<ptr->data<<endl; if ((ptr->right)!=NULL; disptree(ptr->right); } i'm getting a segmentation fault at the red line. i cannot understand what's the problem.... (3 Replies)
Discussion started by: vijaymrt
3 Replies

5. Shell Programming and Scripting

Insert string 'NULL' where there is a null value

I have an input file having 7 fields delimited by , eg : 1,ABC,hg,1,2,34,3 2,hj,YU,2,3,4, 3,JU,kl,4,5,7, 4,JK,KJ,3,56,4,5 The seventh field here in some lines is empty, whereas the other lines there is a value. How do I insert string NULL at this location (7th loc) for these lines where... (8 Replies)
Discussion started by: zilch
8 Replies

6. Shell Programming and Scripting

NULL checking

Hi I need to check the output of a string to null. For eg the output I get for $KIT is empty. So want to echo something when the output is empty. How can I do that? Thanks in advance (6 Replies)
Discussion started by: Ananthdoss
6 Replies

7. Shell Programming and Scripting

working with null elements in an array

i have an array (with each element length "n") which is dynamic and has alphanumeric characters. i want to check if any of the elements of the array are null and replace it with a string of "n" zeros for that element. can you suggest me a code for the same. (1 Reply)
Discussion started by: mumbaiguy07
1 Replies

8. Shell Programming and Scripting

Checking for null condition in a UNIX variable

i have this code for i in `cat sql_output.txt` do -- some script commands done sql_output.txt has 1 column with employee_ids If the sql_output.txt is null then the do loop should not execute. How can i implement this. for i in `cat sql_output.txt` If i is null or empty then ... (5 Replies)
Discussion started by: rafa_fed2
5 Replies

9. Shell Programming and Scripting

Finding null column value using array

hi, Am trying to find a solution for finding a null column value inside a loop using array. for eg: two three five From the above array myarray,myarray and myarray having null values. But when am trying to check that space using some condition its not working. for (( i=0;... (4 Replies)
Discussion started by: rogerben
4 Replies

10. Linux

Issue in inserting null string in array

I am getting some values from a file and putting them in an array..but the null strings are not getting passed to the array. So during printing the elements ,the null string is not showing in the output. during array size calculation it is also excluding null.Please let me know how to do it. # cat... (2 Replies)
Discussion started by: millan
2 Replies
Tcl_SaveResult(3)					      Tcl Library Procedures						 Tcl_SaveResult(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tcl_SaveResult, Tcl_RestoreResult, Tcl_DiscardResult - save and restore an interpreter's result SYNOPSIS
#include <tcl.h> Tcl_SaveResult(interp, statePtr) Tcl_RestoreResult(interp, statePtr) Tcl_DiscardResult(statePtr) ARGUMENTS
Tcl_Interp *interp (in) Interpreter for which state should be saved. Tcl_SavedResult *statePtr (in) Pointer to location where interpreter result should be saved or restored. _________________________________________________________________ DESCRIPTION
These routines allows a C procedure to take a snapshot of the current interpreter result so that it can be restored after a call to Tcl_Eval or some other routine that modifies the interpreter result. These routines are passed a pointer to a structure that is used to store enough information to restore the interpreter result state. This structure can be allocated on the stack of the calling procedure. These routines do not save the state of any error information in the interpreter (e.g. the errorCode or errorInfo variables). Tcl_SaveResult moves the string and object results of interp into the location specified by statePtr. Tcl_SaveResult clears the result for interp and leaves the result in its normal empty initialized state. Tcl_RestoreResult moves the string and object results from statePtr back into interp. Any result or error that was already in the inter- preter will be cleared. The statePtr is left in an uninitialized state and cannot be used until another call to Tcl_SaveResult. Tcl_DiscardResult releases the saved interpreter state stored at statePtr. The state structure is left in an uninitialized state and can- not be used until another call to Tcl_SaveResult. Once Tcl_SaveResult is called to save the interpreter result, either Tcl_RestoreResult or Tcl_DiscardResult must be called to properly clean up the memory associated with the saved state. KEYWORDS
result, state, interp Tcl 8.1 Tcl_SaveResult(3)
All times are GMT -4. The time now is 04:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy