c - How can I quote a variable? -
how can quote variable in c?
i have this:
inputpass[0] = selectorvalue; and doesnt homecoming expected result.
works fine with:
inputpass[0] = '1'; i need set variable selectorvalue between single quotes. ¿how can that?
i tried inputpass[0] = "'" + selectorvalue + "'" didn't work.
i want create char array, , selectorvalue integer variable. that's why want set between single quotes.
i don't know why want quot variable, think perchance missunderstanding way in characters work in c. in c, character constant, '1', has value of type int, is, integer. if variable selectorvalue integer, nil needed do.
i imagine selectorvalue integer 1, 2, 3, ...
in case, if want convert character, have add together ascii value of '0' integer, in way:
inputpass[0] = '0' + selectorvalue; but approach works values between 0 , 9. so, carefull.
anyway, guessing, because question not clear.
finally, in c, makes difference between ascii code of character, illustration 'a' (which 64) , character itself, comes in moment have show information.
printf("%c", 'a'); // prints character: printf("%d", 'a'); // prints ascii value of character a: 64 the op explains want "add" single quotes, explicitely.
i think accomplish complicated, if not impossible. in moment cannot see or remember way that. (to add together double quotes easy, using operator # in macro definition).
c variables quotes
No comments:
Post a Comment