View Poll Results: This question, good or bad?

Voters
3. You may not vote on this poll
  • Good

    1 33.33%
  • Bad

    2 66.67%
Results 1 to 5 of 5

Thread: Smart People

  1. #1

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Post 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

  2. #2
    Zaei
    Guest
    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.

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width