-1

I got this error:

exit status 1 stray '#' in program

How can I remove this error..?

int keys = {1,2,3,A,4,5,6,B,7,8,9,C,*,0,#,D};
4
  • 3
    you should use char literals instead of numbers, operators, identifiers and macros. just place every single list entry in single quotes like this {'1', ...'#', 'D'}
    – Kwasmich
    Jul 1, 2019 at 7:27
  • 1
    only some of the elements in keys are integers ... you need to rethink what you are doing
    – jsotola
    Jul 1, 2019 at 7:29
  • 1
    If s/he quotes every one that will be OK. A single quoted character can be stored in an int.
    – Nick Gammon
    Jul 1, 2019 at 7:46
  • "How can I remove this error?" Well, just delete your code from the beginning to the end and this will certainly "remove the error". Done. Now, please, make an effort to ask questions that at least makes some basic sense. Yours currently doesn't make any. Until you tell us what you were trying to do and what is that # doing there, there's no way to answer your question.
    – AnT
    Jul 2, 2019 at 0:12

1 Answer 1

3

There are several -more or less severe- issues in your one line of code

const char keys[] = {'1','2','3','A'
                    ,'4','5','6','B'
                    ,'7','8','9','C'
                    ,'*','0','#','D' };

( Find the differences :) )

Depending on your usage, you eventually even need a 2-dimensional array

const char keys[4][4] =  ...

Not the answer you're looking for? Browse other questions tagged or ask your own question.