Storing values in strings

This is a discussion on Storing values in strings within the C Programming forums, part of the General Programming Boards category; I was wondering if there was a way to have a string array to store both numbers and letters. For ...

Storing values in strings

I was wondering if there was a way to have a string array to store both numbers and letters. For example, Im writing a digital signal generator program, the user is to input values 0-9,#,*,A-D. My teacher has never went over strings until today, in which he gave a 5 minute overview of it. So Im completely confused.
I need to store these values in an array so i can use a switch statement to pick different frequencies. For example if the 0th value in the array is A the frequency would be 697 HZ. The only problem is that I don't know how to use strings to read a value in the array everytime I try it freezes on me.

I was wondering if there was a way to have a string array to store both numbers and letters. For example, Im writing a digital signal generator program, the user is to input values 0-9,#,*,A-D. My teacher has never went over strings until today, in which he gave a 5 minute overview of it. So Im completely confused.
I need to store these values in an array so i can use a switch statement to pick different frequencies. For example if the 0th value in the array is A the frequency would be 697 HZ. The only problem is that I don't know how to use strings to read a value in the array everytime I try it freezes on me.

everything is a digit. well, I guess it is kinda wrong. 0 or 1 in sequence. true or false.

0110 0001 is an 'a' on the ascii therefor a number.

if you do printf("%d", 'A'); you get the number for A
or do a printf("%c", 65); you will get A. C doesnt care. It will look it up for you basicly but its still all just digits to C.
Even the * (42)and an ][93]have digit representations. Also Numbers such as 0, 1, 2, 3 have the same digit representation.

for 0 it would be 48 so
Do a printf("%c", 48);
and it will print a zero.
C does the work for you in these cases but its all working with digits.

When you do a
char letter = 'a';
its not storing the letter a it is storing the binary number that it looks up for you.

A 'digit' is each of the basic numbers comprising a number system. In base ten, that would be 1 - 9 and 0. The alphabet isn't "digits". Also, not all character sets use the same representation for each character, so 'a' isn't 65 in every set.

Also, not all character sets use the same representation for each character, so 'a' isn't 65 in every set.

The term you were looking for isn't digit, that was my point.

Quzah.

I specificly mentioned the ascii character set. Its upon the OP to search the meaning.

For his assignment he doesn't need a tutorial on string functions.
what is probaly easiest is to do a char array holding the values of the characters and use a char to store the user input and compare it against the array. Its really just that simple.

I was wondering if there was a way to have a string array to store both numbers and letters. For example, Im writing a digital signal generator program, the user is to input values 0-9,#,*,A-D. My teacher has never went over strings until today, in which he gave a 5 minute overview of it. So Im completely confused.
I need to store these values in an array so i can use a switch statement to pick different frequencies. For example if the 0th value in the array is A the frequency would be 697 HZ. The only problem is that I don't know how to use strings to read a value in the array everytime I try it freezes on me.

What i think is that u can take a char array input each of the characters(alphabets or digits) and terminate that with a NULL character.this will be the rquired string. Then using a loop u can access all those characters. And within that loop u can use ur required switch statement with a case for digits and alphabets.

@ stricky C
i completely agree with u that everything in C is stored as combination of bits (binary digits).

By associating with wise people you will become wise yourselfIt's fine to celebrate success but it is more important to heed the lessons of failureWe've got to put a lot of money into changing behavior