C++ :: Print Chars As Keys Are Hit?

Mar 31, 2012

I found this method

Code:
TCHAR win_getch()

(below) on a website which is used for printing the characters as the keys on keyboard are hit i-e without hitting the ENTER key. This method is used in a while loop like this

Code:
while ((c = win_getch()) != 13)
{}

I wanted to know why is the character compared to

Code:
13
i-e
Code:
if((c = win_getch()) != 13) then do something

Code:
/**
* This function will simulate the getch() function from conio.h.
* Note that this does not work for special keys like F1-F12, arrow keys,
* even the ESC key does not seem to work with this function.
* @return TCHAR read from input buffer.
*/
TCHAR win_getch() {
DWORD mode;
TCHAR theChar = 0;

[code]....

View 2 Replies


ADVERTISEMENT

C++ :: How To Allow Pressing Some Keys On Keyboard

Jul 4, 2014

how can I allow pressing some keys on the keyboard in C++? I mean, when you are in the console and you are only allowed to press numbers before pressing enter, for example.

View 6 Replies View Related

C :: How To Make A Menu That Uses Arrow Keys

Feb 12, 2015

My program uses a menu that easily facilitates a person to navigate trough out it but im stuck on a part and I cant go to menu3 with the arrows (only use c code not c++)

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
void sleep(long int interval) {
for(int i=0;i<interval*1000;i++);}

[Code]...

View 6 Replies View Related

C++ :: How To Access A Specific Member If Keys Are Same

May 19, 2013

I understand what a map is and all, but what purpose does multimap serve?How can you access a specific member if the keys are the same?

View 8 Replies View Related

C++ :: Searching For A Container With Multiple Keys

Apr 7, 2013

I need a container which has multiple keys. The number of keys, which are related to a value, is not constant, but it is small. (less than 10). I have tried to do this with std::map, but things are working only with a constant number of keys per value.

Something like this

key1 ----|
key2 ----|--------- value1
key3 ----|

key4 ----|--------- value2
key5 ----|

View 11 Replies View Related

C++ :: Function Keys (F1-F12) Encountered A Logic Bug

Feb 27, 2014

I was developing an exercise program for myself (note: not a project in school) to enhance my programming skills in C++ then I encountered a "logic bug" (that's how I call it :D ) I think. I googled stuffs I need to know and ended up to post my question here.

Here's the scene:

1. When using GetAsyncKeyState I can capture Function Keys [F1-F12, etc..]

2. While doing and having fun to my exercise program, I suddenly noticed that whatever key I pressed from the keyboard {example: asdfkj], it keeps the keys entered and brings to a "field" that accepts user input.

What you should do...

1. Press any key (example: asdfisdjfisdjff) then proceed to press F1. And see what happens. I don't know how to erase what I have entered before pressing F1.

here's the code.

#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
void gotoxy();
void gotoxy( int column, int line ) {

[code]....

View 5 Replies View Related

C# :: TextBox Navigation Using Arrow Keys

Mar 2, 2014

So I have assigned this method to each TextBox. It works fine pressing the left arrow and right arrow, but for some reason will not work using the up and down arrows. I have tested the string, using MessageBox and it is correct...the loop even proves it finds a matching TextBox. It is correct as in it displays the TextBox name it should be selecting but doesn't. I have no clue! Now the first select method is the one I want to use, I used the loop to check to see if it was even finding a match. It does find it but doesn't select it. The naming convention for my text boxes is r1c1 where the first number indicates the row and the second number is the column. There are 9 rows and 9 columns. This SHOULD be working but for whatever reason it is not. I've even put a message box inside the if statement for the up and down keypress check and it pops up when i press up or down.

private void Navigate(object sender, KeyEventArgs e) {
TextBox input = (TextBox)sender;
string nextBox = input.Name.ToString();
if (e.KeyCode == Keys.Left) {
if (int.Parse(nextBox.Substring(1, 1)) > 1 && int.Parse(nextBox.Substring(3, 1)) == 1)

[Code] ....

View 7 Replies View Related

C++ :: Where Registry Keys For Allowed Applications Stored In Windows 8

Sep 4, 2014

I'm trying figure out how Windows Firewall functions by experimenting with Bittorrent's add exception to windows firewall option, I deleted the entry from the Firewall options and also located that the regkeys are in HKLM/System/CurrentControlSet/Services/SharedAccess/Parameters/FirewwallPolicy but I can't figure out what registries are made when an application is added as an exception in the Windows Registry.

View 6 Replies View Related

C++ :: Program To Generate Pairs Of RSA Keys Using Small Prime Numbers

May 21, 2012

I have been writing a program to generate pairs of RSA keys using small prime numbers. I have been using mpz_invert() to get a value for d for the private key. On small prime numbers it calculates the correct value, but on larger primes it calculates incorrect values.

I'm assuming there must be an upper limit to the values the mpz_invert() function can handle? If so, what is this limit to avoid erroneous values?

View 1 Replies View Related

C++ :: Looking For Chars In String

May 20, 2013

I'm looking for a algorithm to search portions of string that have the same caracter. The only possible values are: a,n and g

Char index: 0 1 2 3 4 5 6 7 8 9 RESULT
------------------------------------------
Example 1: a g g g a a 0,4
Example 2: g g g a n n a 0,3
Example 3: a g g g g g g a 0,7
Example 4: g g g g g g g 0,6
Example 5: g g a a g a a a g 0,2,3,5,7,8

View 4 Replies View Related

C :: Swap Chars Using Getchar

Sep 23, 2014

This is for homework . Must use only getchar and putchar

Code:

int main(void) {
int pch; //first
int ch; //second

[Code]....

And it works , but i need to hit ENTER two times when i have 3,5,7... chars to print result.

View 6 Replies View Related

C :: Reading In A File Of Chars Until EOF

Apr 13, 2013

I'm working on a homework project, and it requires me to read in a file of chars into an array, and then do stuff with that array.

Anyways, I have the first part written, where I'm just trying to read in my data.txt file, and I thought I had it written well. It compiles, but then it seg faults, and I'm not sure why. I used calloc for the array, but maybe I misused it? Or is it in my EOF statement? I'm still not sure if that's coded correctly. I need to get past this so I can start testing the other parts of my code.

Code:
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[] ) {
/* Local Declarations*/
int i;
int *ptr;
char tempc;

[Code] .....

View 1 Replies View Related

C++ :: Convert Chars To UTF-8 Hex Strings

Sep 27, 2013

I am trying to convert some chars to UTF-8 strings...

Example:

std::string gethex(char c) {
/* EXAMPLE
if (c == 'é')
return "%c3%a9";
I need a function that converts chars like "á, é, í, ã" to UTF-8 hexadecimal strings...
*/
}

[Code] .....

[URL] .... does it. Choose UTF-8, type some character and click 'Url Encode'.

View 14 Replies View Related

C++ :: Comparing Chars In A While Statement

Jul 1, 2014

I am trying to do this but it can never seem to work.

#include <iostream>
using namespace std;
int main () {
char charOne;
cin.get(charOne);
cin.ignore(1000, '

[Code] .....

Basically i want to keep looping until i enter an a or A (also does this apply to if statements as well?)

View 6 Replies View Related

C/C++ :: Put Special Chars In A Message

Apr 10, 2014

I'm trying to put in my messages, in my program, some special chars but when i try something like the following code, i get the output below.

#include <stdio.h>
int main( ) {
printf("Trying this char: %c", 160);
printf("Trying this char: %c", 163);
return 0;
}

Output:
Trying this char: �
Trying this char: �

How can i put those special chars? I would like to use: é, ú, ç, à, Ú, À, ...

View 14 Replies View Related

C/C++ :: Printing Out Unicode Hex As Chars

Feb 10, 2014

I'm writing a school assignment that writes/reads user input into and out of a binary file.

I've gotten the write part to work, but now I need to be able to read that file back in and display it as a string.

I think I should be using fread() and read my file into an array of int's right? But when I try printing out that array I get a whole bunch of numbers that don't match the hex code in my file.

How do I read in a binary file and print it out as a string?

View 4 Replies View Related

C# :: Reverse Chars Of String

Aug 7, 2014

I have a problem with my code. I just have to reverse the chars of a string, but it adds a /n that I can't delete.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ch05Ex05._5 {

[Code] ....

View 5 Replies View Related

C :: Converting Random Numbers Into Chars?

Apr 3, 2013

I am having difficulty completing 7th last line below I marked the line with an arrow.

Code:
int main(void) {
int MaxNum, /*number of random nos to generate */
i, /*index */
value,

[Code].....

View 4 Replies View Related

C :: Adding Chars From File To Array

Jan 29, 2014

lets say we have a txt that contains this

| | | | |*| |
| | | |*| | |

and that symbolizes a 2x6 char array and we want to take only the symbols inside the || and place them in a 2x6 char array. how do we do that?

View 1 Replies View Related

C :: How To Convert From Array Of Chars To Strings

Jan 13, 2014

As a part of a program I am supposed to write, I would like to receive a string from the user (for example: "Hi my name is Joe").

obviously, the string is inserted to an array of chars (arr[0]='H', arr[1]='i', arr[2]=' ',... and so on).

What I would like to do, is to put each word separately in each array cell (for example arr[0]='Hi', arr[1]="my"..., and so on). How can I do this? (I can not use any functions, unless I write them myself).

View 8 Replies View Related

C++ :: Remove Non-Displayable ASCII Chars

Jan 7, 2014

How to give input with text for this function.i already create function for this but i dn't know give input as non ASCII value(0-32) that Cobain with string or simple text.

View 1 Replies View Related

C++ :: If Multiple Same Chars Found Then Drop One

Nov 20, 2013

For some reason my code is not couting right. My function is supposed to decipher some code that if it has multiple same chars then it drops one. Example aabbyfkk --------> abyfk. But it couts abyffkk . For some reason it is not getting rid of the extra f and k chars.

string decrypt (string encrypted) {
string deleted, tmp;
int i, pos, n, j=0, z;
tmp=encrypted;

[Code] ....

View 3 Replies View Related

C/C++ :: Sort Out Input - Getting Rid Of Chars And Only Using Numbers

Apr 2, 2014

I was supposed to sort out an input, getting rid of chars and only using the numbers. So 5a6g7we87hj9 would become 567879. I might be wrong in some way, but I used

if (scanf("%d", &n) {
printf(" %d", n);
}
else {
printf("Error);
}

and it sorted correctly.

View 1 Replies View Related

Visual C++ :: Best Way To Read Array Of Chars

Jan 16, 2014

I am receiving a max of 50000 bytes from a socket.

char packet1[50000];
recv(Socket, (char*)&packet1, 50000, 0);

What is the best way to read those bytes? Let's say I need to see if bytes 14-15 and byte 16-17 equal each other.

Only thing I can think of is to create a buffer array of 2 chars, and feed the bytes into those and compare them. Is that right?

View 5 Replies View Related

C :: How To Account For Different Number Of Chars In Array Of Names

Dec 9, 2013

I am trying to make a for loop that will print out chars in an array while using a #define before main. My problem is that each name has a different amount of chars in it. How do you account for that when you are trying to define a size? For example, I am playing around with the numbers and I just put 7 in for size:

Code:
#include <stdio.h>
#define sizeOf 7
//char personName( char * name[] );
char printName ( char * name[]);

[Code] .....

View 8 Replies View Related

C :: Replacing Individual Chars In A String Array?

Nov 16, 2013

I'm trying to right the function that puts the correct letters in the right positons being reported from my previous compareletter function for my game of hang man and its not updating the word in progress array. Here's my compare letter function that's working correctly:

Code: //function that returns the index of the letter that the user has guessed or Code: //-1 if the letter isn't in the word
int CompareLetter(char array[], char guess, int numLetters)
{
int i;

[Code....

However, this isn't changing any of the position of the asterisks in the word in progress array positions 0-3.

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved