Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Showing results 1 to 40 of 242
Search took 0.05 seconds.
Search: Posts Made By: jim mcnamara
Forum: C Mar 19th, 2008, 2:38 PM
Replies: 15
Views: 706
Posted By jim mcnamara
Re: Causing a Seg Fault on Purpose

grumpy, narue and L7sqr gave you the answer.

I have a lot of different unix OS's and architectures here at work. One is a PA_RISC2 64 bit machine. It allocates 4096 bytes of memory minimum to a...
Forum: Bash / Shell Scripting Feb 11th, 2008, 2:29 PM
Replies: 2
Views: 338
Posted By jim mcnamara
Re: Switch User

The /etc/sudoers file dictates who is allowed to sudo to what account.
When setup up correctly:

sudo su - <someusername>
ls
exit # get out of sudo
requires no password.

If you set up so that...
Forum: Bash / Shell Scripting Feb 11th, 2008, 2:24 PM
Replies: 1
Views: 253
Posted By jim mcnamara
Re: scripting question

echo "Which directory \c"
read directory
tmpfile=/tmp/tmpfile.$$

for file in loaderconfiguration*.xml
do
sed "s|${directory}|$inName|g" $file > $tmpfile
mv $tmpfile $file
done
Forum: C Feb 4th, 2008, 2:23 PM
Replies: 9
Views: 274
Posted By jim mcnamara
Re: Accessing bits

Just in case: the bits in a float have different meanings - sign bits, mantissa, exponent.
For a float this is the IEEE 754 standard, which most, but not all systems ahdere to.
Just like endianess,...
Forum: C Jan 25th, 2008, 10:42 AM
Replies: 13
Views: 414
Posted By jim mcnamara
Re: printf Alignment

Dunno if this helps:

The %n format specifier tells you how many characters have been output at the point %n is encountered in the formatting process. It also is a good place for hackers to attack...
Forum: C Jan 8th, 2008, 4:27 PM
Replies: 12
Views: 414
Posted By jim mcnamara
Re: Calling exit(???) functions

exit(int status) is defined by standard to close open files, stop the executable image from running and to return the value of status to the calling program. In MS this could be windows explorer, a...
Forum: C Dec 18th, 2007, 11:00 AM
Replies: 20
Views: 740
Posted By jim mcnamara
Re: Function returning double pointer ?

In C: int foo(); as a function declaration
does mean there is no parameter specification, which then means you can call foo with different numbers of arguments of differing datatypes and not have...
Forum: C Nov 15th, 2007, 1:06 PM
Replies: 2
Views: 205
Posted By jim mcnamara
Re: Drawing in console (UNIX)

See this for comments about line drawing
http://invisible-island.net/ncurses/ncurses.faq.html
Forum: Bash / Shell Scripting May 4th, 2007, 11:24 AM
Replies: 2
Views: 384
Posted By jim mcnamara
#Bourne shell VARIABLE="something" export...

#Bourne shell
VARIABLE="something"
export VARIABLE
#ksh, zsh, bash
export VARIABLE="something"

OR in a pathname? Do you mean this

if [[ -d /path/one || -d /path/two ]] ; then
echo "At least one...
Forum: C Mar 28th, 2007, 2:20 PM
Replies: 21
Views: 587
Posted By jim mcnamara
For randomness good enough for encryption...

For randomness good enough for encryption purposes,
consult information about /dev/random in the UNIX operating system.
It is implemented in C
Forum: C Mar 9th, 2007, 2:08 PM
Replies: 13
Views: 402
Posted By jim mcnamara
Canonical vs non-cononical terminal I/O? The...

Canonical vs non-cononical terminal I/O?

The setbuf function in stdio is defined to be able to turn off/on buffering. Subsequent fprintf calls are affected. In most implementations, you must call...
Forum: C Mar 2nd, 2007, 10:12 AM
Replies: 21
Views: 587
Posted By jim mcnamara
This is the Knuth PRNG (Pseudo-Random Number...

This is the Knuth PRNG (Pseudo-Random Number generator) that was used in glibc3.1 for Linux, it is reentrant:

int
rand_r (unsigned int *seed)
{
unsigned int next = *seed;
int result;

next *=...
Forum: C Feb 22nd, 2007, 3:30 PM
Replies: 11
Views: 296
Posted By jim mcnamara
Over tcp the default is big-endian. Even Windows...

Over tcp the default is big-endian. Even Windows supports
htonl(unsigned long hostlong);
and
ntohl(unsigned long networklong);

Assuming your floats are IEEE (32bit), then you call these to...
Forum: Bash / Shell Scripting Feb 22nd, 2007, 3:10 PM
Replies: 8
Views: 391
Posted By jim mcnamara
ksh (the shell ) supports exactly what you want -...

ksh (the shell ) supports exactly what you want - it's called co-processes.
talk also does what you want. Both work from the command line.

Both of these are part of any POSIX1b (IEEE 1003.1 2004)...
Forum: C Feb 14th, 2007, 12:17 PM
Replies: 4
Views: 248
Posted By jim mcnamara
If you are dealing a deck of cards, infogeek's...

If you are dealing a deck of cards, infogeek's method is what you want. You can deal a card only once. If you are doing something with "random" selections, then repeats have to be allowed, because...
Forum: Bash / Shell Scripting Feb 9th, 2007, 3:44 PM
Replies: 3
Views: 341
Posted By jim mcnamara
In ksh and bash you can use a limited form of...

In ksh and bash you can use a limited form of regex called pattern-matching

ls *.c lists all of the file that have a . followed by the letter c
ls *.[!c] lists all of the files that have a do and...
Forum: C Feb 9th, 2007, 3:34 PM
Replies: 9
Views: 221
Posted By jim mcnamara
Or he's trying to write shellcode....

Or he's trying to write shellcode....
Forum: C Feb 6th, 2007, 3:08 PM
Replies: 3
Views: 206
Posted By jim mcnamara
Have the child process call sleep(9999); But why...

Have the child process call sleep(9999);

But why do you want that? If this is related your your other post, then I'd guess you're playing around with code, which is a good way to learn.
But, in the...
Forum: C Feb 6th, 2007, 3:04 PM
Replies: 4
Views: 177
Posted By jim mcnamara
The question has no meaning....

The question has no meaning....
Forum: C Feb 6th, 2007, 3:02 PM
Replies: 4
Views: 241
Posted By jim mcnamara
void swap( int *a, int *b) { int t=*a; ...

void swap( int *a, int *b)
{
int t=*a;
*a=*b;
*b=t;
}

int main()
{
int x=1;
Forum: C Feb 6th, 2007, 2:56 PM
Replies: 7
Views: 219
Posted By jim mcnamara
srand(time(NULL) % getpid() ); And DaWei is...

srand(time(NULL) % getpid() );

And DaWei is correct. You want

int choice= rand()%2;
choice ++;

This gives 1 or 2.
If you really want .0 ... .999999 then
double choice=rand();
Forum: C Jan 24th, 2007, 4:55 PM
Replies: 2
Views: 202
Posted By jim mcnamara
1. Borland TC 3.0 does not support threads or...

1. Borland TC 3.0 does not support threads or memory sharing.

2. If you must do this with TC 3.0 use a "lock" file as a sempahore-like object.

3. TC 3.0 is a DOS compiler. DOS does not handle...
Forum: Bash / Shell Scripting Nov 30th, 2006, 2:21 PM
Replies: 2
Views: 276
Posted By jim mcnamara
On a POSIX-compliant unix, tr supports POSIX...

On a POSIX-compliant unix, tr supports POSIX classes -- those [:upper:] things.

echo "enter a word \c"
read aword
aword=`echo "$aword" | tr -s '[:lower:]' '[:upper:]'`
Forum: Bash / Shell Scripting Nov 16th, 2006, 4:28 PM
Replies: 4
Views: 260
Posted By jim mcnamara
look up "here document" on google.

look up "here document" on google.
Forum: Bash / Shell Scripting Nov 16th, 2006, 4:27 PM
Replies: 4
Views: 358
Posted By jim mcnamara
It constitutes a magic number. UNIX can...

It constitutes a magic number. UNIX can interpret the magic number for a lot of files, and then behave accordingly.

#!/bin/ksh
loads the ksh shell for the duration of the script - the script file...
Forum: C Oct 3rd, 2006, 11:03 AM
Replies: 9
Views: 241
Posted By jim mcnamara
It depends on the OS. The Windows API can detect...

It depends on the OS. The Windows API can detect keystrokes, and for Linux you can change the tty to be non-canonical.

This assumes you're just going to wait or loop until the user hits something...
Forum: Bash / Shell Scripting Sep 28th, 2006, 3:27 PM
Replies: 12
Views: 667
Posted By jim mcnamara
Do you want to check the existence of any domain...

Do you want to check the existence of any domain - nslookup?
Options let you specify a domain to limit the search. You can also specify the
DNS box.

I'm not sure what you meant by a DNS domain in...
Forum: Other Programming Languages Sep 18th, 2006, 10:20 AM
Replies: 2
Views: 162
Posted By jim mcnamara
One strategy is to install the executable with...

One strategy is to install the executable with "knowledge" about what directory it allowed to run in, for example C:\Program Files\Appname\bin
or /usr/opt/local/bin

When it starts it checks to see...
Forum: Sed and Awk Aug 28th, 2006, 10:19 AM
Replies: 3
Views: 559
Posted By jim mcnamara
> file truncates (sets the file pointer to the...

> file
truncates (sets the file pointer to the start of an empty file) a file.
It happens before grep runs. Grumpy gave you the workaround.

grep 'stuff ' file1 > tmpfile
mv tmpfile file1
Forum: Sed and Awk Aug 23rd, 2006, 4:43 PM
Replies: 0
Views: 366
Posted By jim mcnamara
Let's try efficiency - a coding challenge

Suppose that we have a really big number file, say 20 MB of numbers in a
single column. It has duplicates. Let's call this file bigfile.

You are given another file, which is much smaller, say 20000...
Forum: Bash / Shell Scripting Aug 23rd, 2006, 3:38 PM
Replies: 5
Views: 301
Posted By jim mcnamara
The print command line utility will round...

The print command line utility will round numbers.

z=2.111
printf "%.0f\n" $z


stick a :; between do and done That's a colon semicolon

Finally, I don't understand what you mean by reference...
Forum: Sed and Awk Aug 17th, 2006, 8:46 AM
Replies: 2
Views: 459
Posted By jim mcnamara
I came up with: sed...

I came up with:

sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'
Forum: Sed and Awk Aug 16th, 2006, 4:50 PM
Replies: 2
Views: 459
Posted By jim mcnamara
sed challange

This forum is near death. Maybe some interesting activity will restore it to life.

Challenge - write a simple sed script to reverse a string or file:

prompt$> echo "hi there" | sed 'your script...
Forum: C Aug 11th, 2006, 1:50 PM
Replies: 10
Views: 333
Posted By jim mcnamara
od -c filename.txt > newfilename.txt od -c ...

od -c filename.txt > newfilename.txt

od -c ASCII dump
od octal
od -x hex
Forum: Other Scripting Languages Aug 10th, 2006, 6:52 AM
Replies: 6
Views: 408
Posted By jim mcnamara
Also. When you have a WHERE clause you return...

Also.

When you have a WHERE clause you return fewer records, using less direct I/O compared to a full-table scan. This gets down to size of the table - ie., number of records in the table. You are...
Forum: Other Web Development Languages Aug 2nd, 2006, 1:50 PM
Replies: 4
Views: 332
Posted By jim mcnamara
Are you encoding UTF-8?

Are you encoding UTF-8?
Forum: C Jul 19th, 2006, 2:46 PM
Replies: 9
Views: 282
Posted By jim mcnamara
They can also be macros for fopen and fread. And...

They can also be macros for fopen and fread.

And the C99 standard for freopen is to return a stream identifier, having tried to close the existing one first, with the new one aimed at another file. ...
Forum: C Jul 17th, 2006, 2:18 PM
Replies: 24
Views: 499
Posted By jim mcnamara
You should understand that float and double are...

You should understand that float and double are floating point numbers.
It is impossible for them to store numbers like 83.39 exactly out to umpteen digits. That is NOT how computers work.

Read...
Forum: C Jul 14th, 2006, 12:14 PM
Replies: 7
Views: 304
Posted By jim mcnamara
PS Microsoft has been anything but open about...

PS Microsoft has been anything but open about Windows Internals.

Linux is the exact opposite - why I work only in UNIX now.
Forum: C Jul 14th, 2006, 12:12 PM
Replies: 7
Views: 304
Posted By jim mcnamara
It's been six years since I did windows...

It's been six years since I did windows internals. There is a masthead called a directory which has a pointer to the the process page table directory, each page directory entry ( a PDE ) points to...
Showing results 1 to 40 of 242

 
Forum Jump



DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:33 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC