View Poll Results: This question, good or bad?
- Voters
- 3. You may not vote on this poll
-
Nov 25th, 2001, 08:38 PM
#1
Thread Starter
Fanatic Member
Smart People
1. What is the difference between Const Char and Char, or Const Int or Int?
2. In what type of situations do I use Const and what type to use normal char,long,int?
3. How to save a String into a Memory? How to retrieve the address of the saved string?
4. How to delete it after saving it?
5. How to generate a randomized number without using "time();ctime();" functions?
6. How to determine the user's OS?
7. How to write a key to the Registry?
8. How to Retrieve a Value from a Key in the Registry?
9. How to delete a Key In the Registry?
10. How to change the color of the text(Console Programs)
11. Is it possible to change the font of the text(Console Programs)
Questions are for the people that are smart.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Nov 25th, 2001, 08:45 PM
#2
1: anything "const" cannot be modified after initialization.
2: use it anytime you want to remind yourself that something should not be changed. Used also in functions where you pass a value by reference, or using a pointer, and dont want to be able to modify the value inside of the function.
3:Strings are always in memory. use new char[len] to create a new string. Save the address in a char* variable.
4: see above (last sentance)
5: srand(rand()) should work fine.
6: API function. Check MSDN
7-9: See above.
10: Yes, Use the SetConsoleTextAttribute() function.
Z.
-
Nov 26th, 2001, 03:56 AM
#3
transcendental analytic
1. & 2. Also const allows the compiler to consider inlining since a variable can be replaced with a constant. Next to performance it also advocates encapsulation and protection; Passing const parameters disallows changing any of it's variables either directly or trough any non const functions. Const should always replace #define macros, because they are type safe.
3. Strings can be stored in local buffers as well, which is a better solution if you want to use memory more efficiently and perform better: char[buffersize] where buffersize is constant. Stings as other variables are accessible trough their name, if not then they are out of scope, which means you tried to access it where you earlier disallowed it to be.
4. when a buffer lifetime ends depends where you define it, usually it only exist until the {} block ends in which it is defined. C Strings on the heap are not automatically removed and have to be manually removed with delete[] Cstring.
7-9 check out the references on these in msdn:
RegOpenKeyEx
RegCloseKey
RegQueryValueEx
RegCreateKeyEx
RegSetValueEx
RegDeleteKey
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 26th, 2001, 09:05 AM
#4
6. Since a program has to be compiled for another OS on another compiler, it's not necessary to find out which system it is running on: either your program doesn't care if it's totally ANSI, or it won't compile (an app using WinAPI can NEVER work on a Mac)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 29th, 2001, 11:20 AM
#5
6. Or do you mean find out the windows version?
GetVersionEx is what you want then.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|