All of the UNIX OS is written and maintained in C - well some asm. GLIBC, all of the the Linux stuff as well.

What was your sample size when you came to this conclusion?

You can pass the value to another function - and name the variable something else. But you are not gaining anything by doing that.
void refoo(int newname)
printf("variable newname=%d\n", newname);

void foo(void)
int oldname=13;
printf(" variable oldname=%d\n", oldname);
As long the variable is in scope the name does not/ cannot change. oldname has function scope in the example above.

I have no idea why the original coder wrote that stuff, except it appears the s/he did not know about the standard C library date/time functions.

date arithmetic is best done with that library - convert a date/time to a struct tm, convert the struct tm to epoch seconds. Do the same thing with another time or date. Now you can add subtract or whatever - like what date & time was it 48 days ago? You don't have to worry about leap years, for example.

Work backwards to get a new date.

The functions you need are
gmtime or localtime

You also have to learn what goes into struct tm, so you can build one if your system does not have strptime.
here is some help:

[QUOTE=nehamore;525444]hey thanks for ur help but can u please elaborate on this...what should i add to my code so that it works the way i want it to work?[/QUOTE]

It sounds like you are coding UNIX. From the man page for system:
If the return value of system() is not -1, its value can be decoded
through the use of the macros described in <sys/wait.h>. For
convenience, these macros are also provided in .
Generally, that would be WEXITSTATUS(system("./myscript") );
Try: man 2 wait or info wait.

date -u causes UTC date/time to be displayed - FYI.

If you format date like this:

today=$(date +%Y%m%d)

you get a value like 20080111, this is a number - an integer.

When you split the input reformat it:


then compare integers:

if [[ $today -ne  $newdate ]] 
       echo "bad date"

DOS network programming is not directly supported by TURBO C. If someone assigned this task to you then that person must have some linkable files to supply TCP/IP support.
This stuff is VERY old. TURBO C should be banned from classrooms. IMO.

There were some network support libraries here:

What narue meant - flags were set so the compiler put symbol names in the image file. When flags are set NOT to output symbols, then you get assembler.

What code have you written so far?

Short answer would be to have a while loop controlled by the totalinsert and money variables
while( totalinsert < money)
/ ask for money here, add it to total insert /
/ you get here when you have enough totalinsert /

for i in $(cut -f 1,3 -d: /etc/passwd)
echo "${i#:}" "${i%:}"

This lets you see what is going on. [code]${i#:}[/code] is parameter substitution- returns the value just before the colon - a number that is the user id.
}[/code] returns the username, so:
arr[number] = name

[code]${i%:}[/code] was changed from [code]${i%: } [/code] which doesn't work, by the way.
Try man (or info) for bash or ksh. This is called parameter substitution using a POSIX shell. It finds substrings.

Do you mean 'will the compiler complain' - no.
'Is it a good idea' - Again, probably not.

Reentrant functions should have all of their data passed to them as arguments, and not use global data structures. Semaphores are traffic cops for access to global objects or shared objects.

This sounds like a threads design problem. What are you trying to do?

Consider calling stat() to get the filesize first. Open the file, then move the file pointer forward to some arbitrary place.

If you assume no last line is ever longer than say, 200 characters,
then fseek() to within 200 character size units of the end of the file.
fread in the last bit of the file into a buffer.

Now you can apply what Narue indicated - you have a container that you can "backwards read" from to get the last line of the file. If you need the last 10 lines, then adjust the file pointer positioning scheme.

If you want to see a generalized algorithm for this, consult the coreutils source for the "tail" utility at



export infile=filename
perl -e '
use Time::Local;
$mytime = timelocal(0,$ARGV[4],$ARGV[3],$ARGV[1],
$ARGV[0] - 1,$ARGV[2] - 1900);
print "$mytime\n";
' $1 $2 $3 $4 $5

keep="None found"
while read record
echo "$record" | tr -s '/' ' ' | tr -s ':' ' '| \
read mon day yr hr mins dummy
filedate $mon $day $yr $hr $mins | read value
if [[ $value -lt $minallowed || $value -gt $maxallowed ]] ; then
if [[ $value -gt $result ]] ; then
done < $infile
print "$keep"


filedate 12 31 2005 23 59 | read min
let min=$min+61
filedate 03 30 2006 23 59 | read limit
compare $limit $min


let min=$limit+61
filedate 06 30 2006 23 59 | read limit
compare $limit $min


let min=$limit+61
filedate 09 30 2006 23 59 | read limit
compare $limit $min


let min=$limit+61
filedate 12 31 2006 23 59 | read limit
compare $limit $min

input file:
10/20/2006 21:24 INFINITY 146144 64213523 N Full Backup
10/13/2006 21:46 INFINITY 144120 60868157 N Full Backup
10/06/2006 21:22 INFINITY 148940 59931237 N Full Backup
09/23/2006 02:14 INFINITY 114239 57878059 N Full Backup
09/15/2006 21:31 INFINITY 137821 58463789 N Full Backup
09/01/2006 23:47 INFINITY 130842 57890925 N Full Backup
08/25/2006 21:34 INFINITY 120475 57706942 N Full Backup
08/11/2006 22:49 INFINITY 105830 54603266 N Full Backup
06/28/2006 23:37 INFINITY 110950 45103754 N Full Backup
output: ...

C version: returns pi/4


double pi_over_4(int n)
double iter=3;
int eveodd=1;
double pi=0.;

for(pi=1.; n>0; n--, iter+=2., eveodd=!eveodd)  
return pi;


Code caving creates a supplanting vector to user-controlled data sets, and is usually a game hacking technique, it's also used in exploits.

Therefore, it's usually an asm code block.
More than that is totally game-specific and platform-specific information that you'd only get at gaming cheat sites that had forums dedicated to a specific game/platform.

I'd search for the game of interest and platform and the word 'hack' or 'cheat'.

If it not a game thing read:
Shellcoder's Handbook by Jack Koziol
considered to be basic source for what you're discussing. ie. commandeering a process's data set to control it.

You did not explain your full data design. So the answer as to why 5 million hash tables =

one hash for one array.

Explain how you need to lookup values in each array. It would help. It might be possible to hash across all arrays.


Your collision rate will be out of this world because you must have zillions of duplicates.
Either duplicate element # in the array or duplicate values in the array. This assumes you do not need to lookup based on the entire array's contents. In that second case, hashing might actually help somewhat.

You will need 5 million different hash tables.
Which meanns that if you are lokking for a given value, say -4, across all of your arrays you will have to consult each hash to see if -4 is in the array and which element it is.

This will result in some performance gain.
I'm assuming that the position of the element and the value in the in the array both have meaning.

It sounds like the data design needs to be rethought -- more than that a hash table will fix your problems. For example, a database can do
highly optimized lookups, like count the number of element #3 that equals 20.

I dunno, don't know enough to about your problem to help, really.

Narue has a site
that has a good explanation of hashing algorithms.

UNIX systems usually come with hcreate, hsearch as an implementation of using Knuth's
original hashing work.

I personally think you've got a data design problem. Possibly you should have put in associative arrays upfront as part of the design.
Hashing added after the fact may only help a little. Depending on how far down the call tree your lookups are embedded in your code.

You have to use either ksh (zsh) or bash to do this - ie., a modern shell with pattern matching.
cd /path/to/files
find . -name '.err' |\
while read file
mv $file "$file".das

Test it somewhere first!

I should have read this earlier.

The answer is no. Unless you are using the Realtime Signal Extension - ie., "realtime signals".

The real question is "Why are you doing this?"
It's not like there aren't USR signals or realtime signals (lots of them) you can't use. No offense, but you're just creating problems for yourself.

find $1 -type f -exec grep -l -e '/*' -e '//' {} \; |
while read file
grep -q ';' $file
if [[ $? -ne 0 ]] ; then
echo $file | grep -q -e '.c$' -e '.h$'
if [[ $? -ne 0 ]] ; then
mv $file "$file".c


sed 'n;s/$/;/' filename > newfilename

You need to use sed, and you have to learn about regular expressions.
based on your data a very specific (not generalized) solution is:
$> echo "Here's some text and ~this bit gets removed~, where tilda is the delimiter." |read var
$> echo $var
Here's some text and ~this bit gets removed~, where tilda is the delimiter.
$> echo $var | sed 's/~[A-Za-z ]*.~//1'
Here's some text and , where tilda is the delimiter.

This will generate a report like you asked for.
nawk '
{ shortcode[$11]=$11
result[$11 $12]++
END{ for( short in shortcode)
for(cause in causecode)
if(result[short cause])
print short, "count", cause, result[short cause]

} ' filename


You will have to write another small script that runs under cron (once every hour) and calls the above nawk code with the correct file name.
awk on Solaris is crippled, you have to use nawk to get the features above.

I don't know sms, so someone else will have to help.

I guess I should add:
stdc allows the use of memcpy with the arguments you stated. What the compiler calls as its own version of run-time memcpy can have any number of aguments. A lot of the API is a simplified wrapper to a much more messy-to-use system call.

It's telling you that you're referencing NULL pointers.

It looks like you're trying to automate vi.

There are such things as "ed scripts" - scripts that invoke the ed editor.
You can use that scripting language easily. vi presents problems because it expects the terminal to be a tty, ed doesn't. Your stdin is a shell script.

man ed

[QUOTE=lastkey;297367]rsh means remote shell. We use this method to access our remote systems. you applied two loops in the solution. But I've said ASM1.log file is on VS01a but not on VS01b, and ASM2.log is on VS01b not on VS01a. so it will give error when executed.[/QUOTE]

Why loop? you only need two rsh lines. You gain nothing by looping.


$1 = path to examine
myscript /path

find "$1" -type d -print |\
while read file
permissions=$(ls -l $file | awk '{print $1}')
echo "$permissions $file"

for i in vs01a vs01b
for k in 1 2
rsh $i echo $(tail -20 /opt/oracle/admin/+ASM/bdump/alert_+ASM"$k".log) >> VS_logs.txt

For "rsh" do you mean rexec or remsh? Or does rsh create a remote shell on remote systems using your OS?