Re:Anything you say will be taken down and used ..
on
Darl Goes to Harvard
·
· Score: 1
char amessage[] = "now is the time";/*an array*/
This tells the C compiler that you want to set up an address space to hold 16 char spaces. The C compiler does this, then assigns a memory space named amessage which holds the start address of the 16 char spaces.
char *pmessage = "now is the time";/* a pointer */
This tells the C compiler that you want to set up an address space to hold 16 char spaces. The C compiler does this, then assigns a memory space named pmessage which holds the start address of the 16 char spaces.
Both statements are equivalent, and both Xmessage variables can be used in interchangable ways: *amessage is the same as amessage[0] *pmessage is the same as pmessage[0]
and given that a char is 1 byte in size: *(amessage + 1) is the same as amessage[1] *(pmessage + 1) is the same as pmessage[1]
There are NO arrays as such in C. An array in C is the start of a contiguous memory space. When you use an indice in the "array" such as amessage[2], then the C compiler examines the sizeof() of the variable type, then moves the pointer sizeof * indice bytes. In the case of a char (1 byte) amessage[2] wil point to amessage + 2 bytes.
If amessage was a struct with a sizeof 30 bytes, then amessage[2] would be amessage + (30 * 2).
Re:Anything you say will be taken down and used ..
on
Darl Goes to Harvard
·
· Score: 1
I never said it was good practise! C lets you shoot yourself. This is both good AND bad.
"Make it idiot proof, and someone will make a better idiot."
"No program is foolproof, because fools are so ingenious."
Re:Anything you say will be taken down and used ..
on
Darl Goes to Harvard
·
· Score: 1
I know that #define is a macro. That is why I said pre-processor.
I started with C many years ago. Probably the modern compilers no longer do this. There used to be a concern with the amount of RAM and disk space apps required.
Re:Anything you say will be taken down and used ..
on
Darl Goes to Harvard
·
· Score: 1
The comparison is between two pointers, one of which has been created on the fly. This would work, but it wouldn't be very much use:
Which is what I said. Memory address comparison.
But it depends on the compiler. Some will optimize memory use by providing a single address to all identical strings (char arrays).
You can have a statement such as
#define MY_NAME "RetroGeek" Then use this everywhere. The pre-processor will replace all MY_NAME with "RetroGeek", which could be in many places.
Which can be bad if your code alters the string on the fly.
Re:Anything you say will be taken down and used ..
on
Darl Goes to Harvard
·
· Score: 3, Informative
No, this is valid code. It will even work since most compilers will find all instances of identical strings and equate their locations:
char *UserName = "DarylMcB";
if (UserName=="DarylMcB") //do something everytime!
It works because UserName is set to the address of the static char array "DarylMcB".
Which pretty well describes ANY technological advance, from the first person to rub two sticks together to produce fire, to the latest Gee-whiz technology.
And once it has been discovered (or invented?), it is here to stay. Once Pandora's box has been opened, you cannot stuff the contents back in.
The best we can do is get the best understanding we can of it, then manage it.
People WILL die, but somewhere down the line it will benefit more people than will die from it.
While the influence of the marketing department varies
I would bet that the Marketing Head has more influence with the CEO than the Engineering Head.
Among other things, the function of the marketing department is more understandable to the CEO than engineering. Plus, to the CEO, the Engineering head is nothing more than a super-geek, and he remembers THOSE from school.
The world is a crazy place where the people making the decisions are usually popular, while the people doing the actual work are not.
What can be done to make manufacturers get their heads into the real world?
Fire the marketing department.
No, really. Some marketing genius does a study, asks some set of people "Hey, we can do this really neat thing, do you want it?". Each marketing genius in the department does this. Now the department goes to the C level and says "All our studies say that people want x, y, z, and also w".
Then the engineering dept gets the WORD FROM ABOVE, and creates the product. Instant plethora of features. The product gets built, goes to stores, and the MAJORITY of people say "whoa, too complicated".
Why do you think that Windows has a dumbed down menu set?
I ended up wiring in a big amp relay through a small power supply. You turn on the switch to the power supply and it kicks in the relay.
It also gives you an OOPS factor. The power supply had a rather large capacitor. You could turn off the switch and the capacitor would take 2-3 seconds to drain off enough to release the relay.
So, hit the switch,..., OH SHIT - hit the switch, and nothing had yet turned off. Saved me a couple of times.
char amessage[] = "now is the time"; /*an array*/
/* a pointer */
This tells the C compiler that you want to set up an address space to hold 16 char spaces. The C compiler does this, then assigns a memory space named amessage which holds the start address of the 16 char spaces.
char *pmessage = "now is the time";
This tells the C compiler that you want to set up an address space to hold 16 char spaces. The C compiler does this, then assigns a memory space named pmessage which holds the start address of the 16 char spaces.
Both statements are equivalent, and both Xmessage variables can be used in interchangable ways:
*amessage is the same as amessage[0]
*pmessage is the same as pmessage[0]
and given that a char is 1 byte in size:
*(amessage + 1) is the same as amessage[1]
*(pmessage + 1) is the same as pmessage[1]
There are NO arrays as such in C. An array in C is the start of a contiguous memory space. When you use an indice in the "array" such as amessage[2], then the C compiler examines the sizeof() of the variable type, then moves the pointer sizeof * indice bytes. In the case of a char (1 byte) amessage[2] wil point to amessage + 2 bytes.
If amessage was a struct with a sizeof 30 bytes, then amessage[2] would be amessage + (30 * 2).
I never said it was good practise! C lets you shoot yourself. This is both good AND bad.
The original point was that:
if ( somepointer == "A string" )
IS valid code.
You mean I can buy the Internet?
I wonder if the book includes a CD?
"Make it idiot proof, and someone will make a better idiot."
"No program is foolproof, because fools are so ingenious."
I know that #define is a macro. That is why I said pre-processor.
I started with C many years ago. Probably the modern compilers no longer do this. There used to be a concern with the amount of RAM and disk space apps required.
The comparison is between two pointers, one of which has been created on the fly. This would work, but it wouldn't be very much use:
Which is what I said. Memory address comparison.
But it depends on the compiler. Some will optimize memory use by providing a single address to all identical strings (char arrays).
You can have a statement such as
#define MY_NAME "RetroGeek"
Then use this everywhere. The pre-processor will replace all MY_NAME with "RetroGeek", which could be in many places.
Which can be bad if your code alters the string on the fly.
No, this is valid code. It will even work since most compilers will find all instances of identical strings and equate their locations:
//do something everytime!
char *UserName = "DarylMcB";
if (UserName=="DarylMcB")
It works because UserName is set to the address of the static char array "DarylMcB".
Am I the only one disapointed by the names of these probes?
Well, we are not there in actuality, but in Spirit
And NASA had the Opportunity to build and send two.
give the user community a wake-up call./i
Stupid users keep hitting the snooze button. They NEVER wake up.
Emails to her have to be completely devoid of usable content to get through.
But isn't that the definition of SPAM?
dixie chicks?
just suck your thumb and you'll find out how drunk you are
That works for me right now. I suck my thumb, and if I bite myself, I'm drunk!
bring horrors to match its benefits
:-(
Which pretty well describes ANY technological advance, from the first person to rub two sticks together to produce fire, to the latest Gee-whiz technology.
And once it has been discovered (or invented?), it is here to stay. Once Pandora's box has been opened, you cannot stuff the contents back in.
The best we can do is get the best understanding we can of it, then manage it.
People WILL die, but somewhere down the line it will benefit more people than will die from it.
Which really sucks if your one of the dead
Or perhaps even nuclear AA batteries
...
Gives new meaning to that Energiser Bunny.
It keep going/2 and going/2 and going/2, and
Sounds like the salesman I overheard explaining WinME.....
new technology that has been abandoned, or even significantly delayed, through alleged (or real) risks
Nuclear energy.
While I am not sure if you are kidding
Only half kidding.
There are some days when I really hate the world, today must be one of them......
Some can actual be removed by a downward tog.
Damn, I want one of these togs.
Hey, when you use it does it tug?
Relax, there are idiots everywhere.
And the more popular something becomes, the more idiots flock to it, just to be "leet".
Maybe we need Slashdot/2, with an intelligence test before you can become a member. Only members can post (thought they can post AC).
Or only people who have a karma above X, and have # of comments above X can become members.
Hey, there's a thought! Maybe Slashcode can be adjusted so that we can filter comments from people with high karma.
While the influence of the marketing department varies
I would bet that the Marketing Head has more influence with the CEO than the Engineering Head.
Among other things, the function of the marketing department is more understandable to the CEO than engineering. Plus, to the CEO, the Engineering head is nothing more than a super-geek, and he remembers THOSE from school.
The world is a crazy place where the people making the decisions are usually popular, while the people doing the actual work are not.
What can be done to make manufacturers get their heads into the real world?
Fire the marketing department.
No, really. Some marketing genius does a study, asks some set of people "Hey, we can do this really neat thing, do you want it?". Each marketing genius in the department does this. Now the department goes to the C level and says "All our studies say that people want x, y, z, and also w".
Then the engineering dept gets the WORD FROM ABOVE, and creates the product. Instant plethora of features. The product gets built, goes to stores, and the MAJORITY of people say "whoa, too complicated".
Why do you think that Windows has a dumbed down menu set?
Why put such a dangerous feature in a program?
Because when the apps were first created we did not have a SPAM problem.
So a legitimate email might have contained a virus and it was good Internet community help to inform the sender about the virus.
Now we have viruses and SPAM which feed off each other and the feature becomes a pain.
I ended up wiring in a big amp relay through a small power supply. You turn on the switch to the power supply and it kicks in the relay.
..., OH SHIT - hit the switch, and nothing had yet turned off. Saved me a couple of times.
It also gives you an OOPS factor. The power supply had a rather large capacitor. You could turn off the switch and the capacitor would take 2-3 seconds to drain off enough to release the relay.
So, hit the switch,
And to quickly test a MODEM (external):
:-))
copy con com1:
ATH1
ATDT911
ATH0
^Z
You also get to test the emergency services
I used to do that.
Until the switch on the power bar fused (after 4 years of on/off).