473,388 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

printing hexadecimal value in c++

Hello,

I'm trying to print the hexadecimal value for a string.
Actually, it was already encoded by my application into utf-8. And I would like to check the converted hex-code.
Could some one please let me know how to print it to a file ?

pFile = fopen ("C:\\myfile.txt","w");
fprintf (pFile, "%X ",c);
The above code didn't work!!

Thanks a lot for your inputs,
Pratap
Sep 13 '10 #1
3 2930
Banfa
9,065 Expert Mod 8TB
Didn't work how?
Sep 13 '10 #2
suppose c contains string "test" , actual hexcode 74657374 is but its printing 40A150

Regards,
Pratap
Sep 13 '10 #3
Banfa
9,065 Expert Mod 8TB
You haven't said what type c is but I am assuming an array of char

char c[100];

You are printing out the hexidecimal representation of the address of the memory that stores the array.

To print the value of the character you need to pass the character to fprintf not the pointer to the array

fprintf (pFile, "%X ",c[0]);

Obviously you will need to repeat for all used entries in the array.
Sep 13 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Todd | last post by:
Our ASP.NET (C#) application accepts form entry and saves inputed data in XML. We are finding that users are sometimes cutting and pasting special characters (from MS Word) into these forms....
2
by: Pushpendra | last post by:
I am storing the encrypted password in xml file which I have saved in unicode format. While I try to read the xml file and create a dataset from it, it shows me the following error ...
1
by: King Kong | last post by:
we are facing this kind of error when we double click the infragistic web grid please help me on this Regards Moid Iqbal Server Error in '/NetworkAccess' Application....
6
by: jasn | last post by:
Hello I am getting the following error message when I try and send an XML sting to a web service, I read somewhere that most web services prefer ascii and some throw errors when using unicode so...
2
by: theonlyzahid | last post by:
Hi, I am getting his weired error when i open my webpage. Parser Error Message: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 13, position 68. Source Error:
1
by: Mike9900 | last post by:
I am getting The ' ' character hexadecimal value 0x20, cannot be included in a name in the following module: public XmlRegistryKey GetSubKey(string path, bool createpath) { XmlElement e = Elem,...
5
by: Just D | last post by:
All, Any valuable idea about subj: "The '%' character, hexadecimal value 0x25" ? I tried to google, but nothing interesting was found. Is it IIS settings problem, user side problem or...
1
by: SanCaziano | last post by:
how can I get get the hexadecimal value of the char insert in a edit control (every time I press a key I want an alert message of its hexadecimal value)
14
by: abhishekkarnik | last post by:
Hi, I am trying to read an exe file and print it out character by character in hexadecimal format. The file goes something like this in hexadecimal 0x4d 0x5a 0x90 0x00 0x03 .... so on When I...
2
by: jerrysc99 | last post by:
I'm getting the following error below. System.Configuration.ConfigurationException: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 8, position 68....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.