question about int arrays and file pointer arrays


 
Thread Tools Search this Thread
Top Forums Programming question about int arrays and file pointer arrays
# 1  
Old 03-15-2011
question about int arrays and file pointer arrays

if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what?
# 2  
Old 03-16-2011
Quote:
Originally Posted by omega666
if i declare both but don't input any variables what values will the int array and file pointer array have on default
If they're stack variables, then undefined. Their contents may depend on your system, compiler, and moon phase. In short: don't use them until you set them somehow.
Quote:
and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what?
Define 'defaults'. If you want 0, set them to 0. If you want 37, set them to 37. If you want NULL, set them to NULL (which just amounts to 0 anyway, but is better for pointers...)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

If statement between different file's arrays

Hi guys Let me explain at first what I'm trying to do. My input file looks like this. 1280 Surfaces Pt 0.00000000000000 0.00000000000000 0.00000000000000 Pt 2.81138845918055 0.00000000000000 0.00000000000000 Pt 5.62277691836110 0.00000000000000 ... (5 Replies)
Discussion started by: saleheen
5 Replies

2. Shell Programming and Scripting

Saving file content in arrays using AWK

Hi, im new to shell scripting. i have a query for which i have searched your forums but coulndt get what i need. i have a file that has two records of exactly the same length and format and they are comma seperated. i need to save the first and the second columns of the input file to 2 different... (11 Replies)
Discussion started by: atikan
11 Replies

3. Shell Programming and Scripting

Reading a .dat file in to 2 different arrays

hi all, i have a data file that contains 2 columns, names and numbers. i need to read names in to a an array call names and numbers in to an array call numbers. i also have # and blank lines in my dat file and i need to skip those when i read the dat file. how do i do this? btw, my column 1 and... (3 Replies)
Discussion started by: usustarr
3 Replies

4. Shell Programming and Scripting

Yet another bash arrays question

Hi all, I have a file that contains many lines, but only a few are of my interest, so I'm cutting it with grep + awk, and the result I get is for example line 0 line 1 line 2 line 3 line n Now I want to store each line in an array "cell" so I can use it later calling to ${array},... (2 Replies)
Discussion started by: TuxSax
2 Replies

5. Shell Programming and Scripting

PERL: simple comparing arrays question

Hi there, i have been trying different methods and i wonder if somebody could explain to me how i would perform a comparison on two arrays for example my @array1 = ("gary" ,"peter", "paul"); my @array2 = ("gary" ,"peter", "joe"); I have two arrays above, and i want to something like this... (5 Replies)
Discussion started by: hcclnoodles
5 Replies

6. UNIX for Dummies Questions & Answers

portability of int arrays from 32 to 64 bit systems

Dear All, I'm porting my scientific program from 32 to 64 bit system (use gcc, CentOS) and feel myself absolutely confused after reading general internet advices for that. Could you help me, please. The question is: can I use "old style" on 64 bit: -------- int * myIntArray; ... (3 Replies)
Discussion started by: German1234
3 Replies

7. Web Development

PHP arrays in arrays

PHP question... I have an SQL query that's pulled back user IDs as a set of columns. Rather than IDs, I want to use their names. So I have an array of columns $col with values 1,7,3,12 etc and I've got an array $person with values "Fred", "Bert", "Tom" etc So what I want to do is display the... (3 Replies)
Discussion started by: JerryHone
3 Replies

8. Shell Programming and Scripting

Struggling with arrays and delimited file

Hi, I am trying to use arrays in my script but can not seem to get it to work. I have a file called sections, this contains headers from a tripwire log file, separated by "@" but could be "," if easier The headers will be used to cut sections from the log file into another to be mailed. ... (5 Replies)
Discussion started by: pobman
5 Replies

9. Shell Programming and Scripting

Arrays & File Reading

Ok; here is the code INCREMENT=0 #Final Count MATCH=0 #Treated as a Boolean declare -a LINEFOUR #Declared Array for FILE in $DIR; do # DIR was declared earlier test -f $FILE && ( TEMP=(sed -n '4p' $FILE) #How do I assign the fourth line of the file to TEMP? This doesn't... (1 Reply)
Discussion started by: Asylus
1 Replies

10. Programming

Question about Arrays

Ok this is probably pretty easy but I'm stuck. My program reads the contents of a txt file and stores the string into a char array called buff. The contents of the text file is a string of a txt file name. So basically buff has this value "file.txt\0". The last part is the null character. I want... (3 Replies)
Discussion started by: johnsonmj
3 Replies
Login or Register to Ask a Question