C :: Converting Letters To Hexadecimal
Jun 3, 2014
i m trying to write a code that would convert a each letter from a text to their decimal images . while i was able to write the part of entering the text , i cant do the converting part , i searched all day on the internet and found nothing.
View 3 Replies
ADVERTISEMENT
Feb 20, 2015
I am new at programming and I have some questions about converting decimal to hexadecimal WITHOUT using .net library. The problem is, that I don't know how to do vice versa. (if you type 1254, program returns 6,14,4. I want programm to return 4,14,6- this is almost hexadecimal number (14 is not converted to "E")). Also the task is, that program has to return value in string form.
static void Main(string[] args) {
int a = 0;
int result = 0;
int n=1000000;
int[] array = new int[n];
Console.WriteLine("Insert numbers");
a = int.Parse(Console.ReadLine());
[Code] ....
View 12 Replies
View Related
Jan 25, 2014
The program is supposed to convert a two digit hexadecimal number to its binary representation. My code runs without any problems but I do not know how to limit the user's input to two digits only. For example the person can input "1ABC" and the program will give the binary representation and I need it to only accept two digit only like for example "1A".
#include<stdio.h>
#define MAX 1000
int main(){
char binaryNumber[MAX],hexaDecimal[MAX];
long int i=0;
printf("Enter a two digit hexadecimal number: ");
[Code] ....
View 8 Replies
View Related
Mar 1, 2013
Write a program in c++ to accept a number and convert this number into binary or hexa decimal or octal number according to the user choice using the concept of array.
View 6 Replies
View Related
Jan 25, 2014
I have my program working, as far as converting the letters to numbers, but i want be able to enter as many numbers as i want. so i figured i could put into a loop asking a question at the end. question being whether the user wants to enter another number or not. also i'm assuming the user enters exactly 7 letters each time. this is my code so far.
const int arSize = 9;
char letters[arSize];
int numbers[arSize];
int count = 0;
cout << "Enter a telephone number expressed in letters. (e.g. CALL loan ( it is not case sensetive))";
for (int i = 0; i < 7; i++,count++)
[Code] .....
View 14 Replies
View Related
Apr 19, 2013
I am new to coding Here is the problem. Have a program prompt the user for a filename to open. Change every alphabetic character in the file to a capital letter. Numbers and special characters should not be changed. Print the output to the screen.
Here is my code so far but i am only returning the last line of text capitalized from the file. I am trying to get the program to display all of the three lines of text from the file capitalized. The program displays the file correctly before i try and convert everything toupper();
Code:
Code: #include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
int main()
{
char line[81], filename[21];
int i;
FILE *inFile;
[Code]...
View 6 Replies
View Related
Sep 9, 2014
I'm trying to write a program that takes input from the user (thats a char) and outputs it to the monitor in hex form.The program is meant to continuously take input from the user then output to the monitor in hex form until an EOF is detected this triggers the program to close.The following code does this except that I get a lower case 'a' at the end of each output.
example:
input from user: ABC
output to monitor: 41 42 43 a
#include <stdio.h>
int main(void) {
char myChar;
[Code]....
View 3 Replies
View Related
Oct 7, 2014
I'm trying to print the full value (in hexadecimal) of a pointer.This is my best attempt so far:
Code:
char *text = "x10x11x12x13x14x15x16x17";printf("%x", &text);
And it obviously doesn't work, best I've gotten is a single byte, but I want the whole lot of bytes.
View 4 Replies
View Related
Feb 21, 2013
I have an array:
Code: int array1[]={0,1,1,0}
I need to convert the entire array to Hexadecimal.
My first thoughts to the approach was to convert the array to a string then strcmp but i cant seem to find how to convert an array to a string either.
How to convert the array to hexadecimal directly? or, How to convert the array to a string to be strcmp'ed?
View 6 Replies
View Related
Apr 21, 2014
Write the function itob(n,s,b) that converts the integer n into a base b character representation in the string s . In particular, itob(n,s,16) formats n as a hexadecimal integer in s .
Note that it says the result is formatted into a hexadecimal integer in the string s. Here is the example provided:
Code:
void itob(int n, char s[], int b) {
static char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int i, sign;
if ( b < 2 || b > 36 ) {
fprintf(stderr, "EX3_5: Cannot support base %d
[Code] ....
Why does digits array hold the full alphabet when the maximum digit for a hex number is f?
View 1 Replies
View Related
Nov 20, 2013
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
[Code]...
1)What should be the best variable for adding two 6-digit hexadecimal,such as 0034AD,0057EA? I would like to use array of character but it seems hard to handle.
View 3 Replies
View Related
Jun 8, 2014
I have to write a code that converts a hexadecimal value to a decimal value.So far I have
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int num;
char g;
int rem;
int main(){
cout << " input num: "; cin >> num;
[code]....
I think i need to put the g and rem value into a string... which I'm not sure how to do since g will be a char value and rem will be a int value... and after I believe i need to then flip the numbers in the string.. oh it has to be in the format of 0000
View 5 Replies
View Related
Feb 25, 2015
I'm taking a university course and one of our first projects dealing with C is to write a hash table (with chaining as a collision solution) that will hash loads of hexadecimal values into the table. I'm just brain storming right now but how practical is it to hash the values by converting them to decimal and working with that value in another function to organize the values? I'm thinking this might take a lot of time and memory because our code will be tested with text files that could have a few lines of hexadecimal addresses or millions of them.
View 2 Replies
View Related
Aug 19, 2013
How to search in C or C++ a hexadecimal patterns within a binary file.
For example:
String1:
Code: 0x44 0x65 0x07
Then, once found, extract those 3 bytes and the next 11 bytes (14 bytes in total).
Finally, from those 14 bytes, print without spaces "bytes 1 to 6", "bytes 6 to 12", and byte "13 to 14".
Then I would like to print last 2 bytes (13 to 14) joined in decimal format.
The output without any conversion would be:
Code:
446507c90688 888000800005 0015
4465072ec918 059173495269 002C
44650700cc01 01811bc90b00 00AB
But the output converting to decimal the last 2 bytes would be:
Code:
446507c90688 888000800005 21
4465072ec918 059173495269 44
44650700cc01 01811bc90b00 171
The sample file is attached, and looks like this:
Code:
06 00 00 80 00 00 00 80 09 3c c9 06 88 88 80 00
80 00 44 65 07 c9 06 88 88 80 00 80 00 05 00 15
37 06 01 00 00 01 00 65 00 00 00 02 00 00 02 00
18 00 00 00 03 00 00 03 00 17 00 00 00 04 00 00
[Code] .....
View 8 Replies
View Related
Mar 10, 2013
I'm trying to convert 4 hex register into floating point value using IEEE 754 floating point format. My device will reply 4 register value. The problem is that it always reply for example 0x10 as 10 when i use getc() hence using char variable to store it is not ideal.
Code:
union {
char c[4];
float f;
} conv;
View 4 Replies
View Related
Oct 2, 2013
i need to code a function that converts an array of 64 bits into a hexadecimal value, the one is tested gives me correct value except for the last hexadecimal letter.
Code:
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <fstream>
#include <cstdlib>
#include <string>
typedef unsigned __int64 Ebyte;
#define length 64
[Code] .....
View 12 Replies
View Related
Jan 19, 2014
#include <stdio.h>
#include <stdlib.h>
int main(int argc, int * argv) {
char buffer[16];
FILE *fp;
unsigned long long test;
unsigned char key[16];
fp = fopen("D:key.txt","r");
[code].....
i searched for a code for reading bytes from a file and i found this one but when i run the program, it doesn't return the bytes written in the file, it returns another bytes / what is the problem?
View 3 Replies
View Related
Oct 13, 2014
I need to write a program in which you do the following:
Define three named constants using the appropriate data types:
DEC_NUM = 65;
HEX_NUM = 0x7a;
LETTER = 'f';
Then display each of these constants in decimal, in hexadecimal, and as a character using cout. Your program will have a total of nine cout statements.
View 1 Replies
View Related
Feb 2, 2015
I currently am stuck at getting the needed outcome data from my RFID card. I got it decoded but now I need to do a few more things in order to get the final card number off the back of the card.
The cryptic value was E********B**0**E** (covered to protect card)
Decrypting it turned into 0000003048D1263B
Now I have 3 more steps to take in order to get to my wanted card number.
Quote
Step 1) Mask off the lower 20-bits (which should give me 0x1263B) I am unsure of how to go about doing that using C++.
View 2 Replies
View Related
Mar 15, 2013
Code:
#include<stdio.h>#define MAX 1000
int main(){
char binaryNumber[MAX],hexaDecimal[MAX];
long int i=0;
printf("Enter any hexadecimal number: ");
scanf("%s",hexaDecimal);
[Code]...
So this is my current code, is there anyway I can reduce the size and use a main function to ask for input and a call function to do all the conversion and return it? I am confused for the past few days trying to figure it out and finally ended up here. Anyway can I write it as a something like this
Code:
int main()
{
//ask for user input hexadecimal into here and call a let's say hex2binary() function
}
int hex2binary(...)
{
//an array with dynamic memory, malloc? and convert it and return values
}
I don't really need the full code, just a simple instruction on how and where to start.
View 2 Replies
View Related
Apr 21, 2014
When I'm trying to implement the AES (Advanced Encryption Standard) in C,
i need to reduce hexadecimal numbers to one byte, modulo 0x11b, but when I want to compute (0x57*0x13)%(0x11b) it returns 0xee instead 0xfe .
View 3 Replies
View Related
Feb 2, 2015
I currently am stuck at getting the needed outcome data from my RFID card. I got it decoded but now I need to do a few more things in order to get the final card number off the back of the card.
The cryptic value was E********B**0**E** (covered to protect card)
Decrypting it turned into 0000003048D1263B
Now I have 3 more steps to take in order to get to my wanted card number.
Step 1) Mask off the lower 20-bits (which should give me 0x1263B) I am unsure of how to go about doing that using C++.
Step 2) Divide by 2 to strip off the lower parity bit (which should be 0x931d). And again, I'm unsure of how to go about doing this in C++.
Step 3) Convert hexadecimal value to decimal value (which would equal my wanted card number). This should be easily done using C++ at this point - though hard to confirm that since I am on step 1).
Code:
const char* original = "0x931d";
unsigned long n = std::strtoul(original, nullptr, 16);
All of this looks to me like RegEX does to most people - complicated and not understanding why it does what it does but gives the correct output.
View 2 Replies
View Related
Mar 16, 2013
I'm just trying to find out if the way I've setup my code currently allows me to count the letters as they occur? I don't yet see how to do it but I need clarification. Ideally the function letterCounter would do the counting but atm I'm just trying to figuring it out in the display function.
View 2 Replies
View Related
Jan 26, 2013
Code:
#include<stdio.h>
#include<string.h>
#define a 9
#define b 9
#define c 3
int main() {
[Code] .....
In practice section there was a challenge to print up numbers in letters up to billion including negatives I didn't look at the solution and came up with this but it is getting difficult after this point....
View 9 Replies
View Related
Nov 14, 2013
These are the instructions: read a number between 1-26 and build a parallelogram in the size (height&width) of the number entered.
Each row of the parallelogram will be built from each capital letter from 1 to the number read (max 26).for example: by entering the number 3, will be printed:
AAA
_BBB
__CCC
for the number 4:
AAAA
_BBBB
__CCCC
___DDDD
I am struggling with how to change each char in every different row, how do I print this parallelogram ?
View 8 Replies
View Related
Jun 1, 2013
I have a text file in which i need to read only selected letters and substitute them with integers to calculate.
Eg:-
In the text file
f2,h1
Here i need to read only the the letters f & h and substitute them with some integer and add them up.
View 1 Replies
View Related