You are viewing our Forum Archives. To view or take place in current topics click here.
[C#] Unlimited user input?
Posted:

[C#] Unlimited user input?Posted:

Z61
  • TTG Fanatic
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
Im trying to teach myself memory hacking (for fun) anyways Im having trouble reading multiple user inputs to modify a integer.
Here is my current Code (allows for 1 user input.)
*Note: I did not add in the subtraction yet, just need to get addition working for now.
*Note2: I have declared 'number' outside of the main void.

 Console.WriteLine("Number is Currently at: " + number);
 Console.WriteLine("Enter '+' to raise the number.\nEnter '-' to lower the number.\n");
 string String = Console.ReadLine();
 while(String =="+") {
         String = null;
         Console.Clear();
         number += 1;
         Console.WriteLine("Number is Currently at: " + number);
         Console.WriteLine("Enter '+' to raise the number.\nEnter '-' to lower the number.\n");


If anyone can help I would appreciate it.
#2. Posted:
MrCheater
  • New Member
Status: Offline
Joined: Dec 21, 200914Year Member
Posts: 34
Reputation Power: 2
Status: Offline
Joined: Dec 21, 200914Year Member
Posts: 34
Reputation Power: 2
            Start:
            Console.WriteLine("Number is Currently at: " + number);
            Console.WriteLine("Enter '+' to raise the number.\nEnter '-' to lower the number.\n");
            string String = Console.ReadLine();
            if (String == "+")
            {
                Console.Clear();//you sure?
                number += 1;
            }
            else if (String == "-")
            {
                number += 1;
            }
            goto Start;
#3. Posted:
M0D1F13D
  • TTG Senior
Status: Offline
Joined: Sep 06, 201014Year Member
Posts: 1,069
Reputation Power: 47
Status: Offline
Joined: Sep 06, 201014Year Member
Posts: 1,069
Reputation Power: 47
loop:
    Console.WriteLine("Number is Currently at: " + number);
    Console.WriteLine("Enter '+' to increase the number.\nEnter '-' to decrease the number.\n");
    ConsoleKey input = Console.ReadKey().Key;
    if (input == ConsoleKey.OemPlus)
        number++;
    else if (input == ConsoleKey.OemMinus)
        number--;
    Console.Clear();
    goto loop;
#4. Posted:
Z61
  • V5 Launch
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
MrCheater wrote
            Start:
            Console.WriteLine("Number is Currently at: " + number);
            Console.WriteLine("Enter '+' to raise the number.\nEnter '-' to lower the number.\n");
            string String = Console.ReadLine();
            if (String == "+")
            {
                Console.Clear();//you sure?
                number += 1;
            }
            else if (String == "-")
            {
                number += 1;
            }
            goto Start;

This seems to do the Job perfectly!

Sorry for wasting your time M0D1F13D.
#5. Posted:
M0D1F13D
  • TTG Senior
Status: Offline
Joined: Sep 06, 201014Year Member
Posts: 1,069
Reputation Power: 47
Status: Offline
Joined: Sep 06, 201014Year Member
Posts: 1,069
Reputation Power: 47
Z61 wrote
This seems to do the Job perfectly!

Sorry for wasting your time M0D1F13D.

No problem, if you get tired of pressing enter I would switch to the ReadKey method.
#6. Posted:
ODST_107
  • Resident Elite
Status: Offline
Joined: Oct 07, 201014Year Member
Posts: 247
Reputation Power: 9
Status: Offline
Joined: Oct 07, 201014Year Member
Posts: 247
Reputation Power: 9
If you are really interested in this stuff, I wouldn't use C#. It has a lot of built in methods for keeping memory nice and clean. It would be better to use C or C++ as it's easier to write unsafe code. Good luck either way! ;)
#7. Posted:
Z61
  • TTG Fanatic
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
ODST_107 wrote If you are really interested in this stuff, I wouldn't use C#. It has a lot of built in methods for keeping memory nice and clean. It would be better to use C or C++ as it's easier to write unsafe code. Good luck either way! ;)

Well im just using it as a basic Hackme for myself
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.