# Thread: Storing values in strings

1. ## 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.

2. Originally Posted by scotty4598
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.
Check out this short well-written tutorial on strings.

Scotty eveything in C is a digit.

4. Originally Posted by strickyc
Scotty eveything in C is a digit.
No. I don't know what you're trying to say there, but it's wrong.

Quzah.

5. Originally Posted by quzah
No. I don't know what you're trying to say there, but it's wrong.

Quzah.
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.

6. 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.

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

Quzah.

7. Originally Posted by quzah
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.

8. read the ascii character set you can store nums as a string.