You are here:

C/Question in C language

Advertisement


Question
Sir, I want a program in C in which text file can be convertd to numeric file,and other i want to generate string characters to ascii codes.


Answer
Hi, Sunny.  I don't quite understand your first question, so I apologize if my answer doesn't quite meet your needs.  If the answer I give doesn't help with the first question, please feel free to ask a followup question and give more details.

Here is the answer to your second question.  When you have a character string in char* format (or a character array), each index of the array is actually contains the ASCII code for each character.  If you were to look at an index of the char* in the debugger and tell it to view as an integer type instead of a character type, it would give the numeric code for the character.  So really, displaying the numeric code of a character versus the character itself all comes down to interpretation of the character array.  If you want to output the numeric code to screen, an easy way to do this with printf would be:

   printf("ASCII code for %c is %d\n", szString[0], szString[0]);

If this isn't what you're looking for, please let me know.  Thanks!

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Joseph Moore

Expertise

I've been programming in one form or another since my brother taught me BASIC when I was 6. I've been programing professionally since I was 20, first web development with HTML, JS, DHTML, CSS, etc., then I became a video game developer, writing code in C, C++, C#, SQL, assembly, and various scripting languages. I've even written my own scripting languages, custom designed for the games I was making. I also dabble in Java, PHP, and Perl. I've worked on pretty much every aspect of game development, including graphics, audio, gameplay, tool, UI, input, animation, and physics.

Experience

I've been writing C code for 12 years, both on my own in my spare time and professionally.

Organizations
IGDA

Education/Credentials
Bachelor of Science in Game Design and Development, Full Sail University, Winter Park, FL

Awards and Honors
Salutatorian and Advanced Achiever Awards at Full Sail; Independent Games Festival Student Showcase winner, 2004; Featured article on Gamasutra about an experimental game developed in 2004

©2012 About.com, a part of The New York Times Company. All rights reserved.