Hi,
can someone tell me when I have code like this:
Code:
#import <stdio.h>
#import <string.h>
int main (int argc, char const *argv[])
{
int userInput, printableInt, x = 0;
char singleDigits[20];
printf("Enter a positive integer or a negative one to quit: ");
scanf("%i", &userInput);
printf("\n\n");
while ( userInput > 0 )
{
printableInt = userInput % 10;
userInput /= 10;
switch (printableInt)
{
case 0:
singleDigits[x] = "Zero, ";
x += 1;
break;
case 1:
singleDigits[x] = "One, ";
x += 1;
break;
case 2:
singleDigits[x] = "Two, ";
x += 1;
break;
case 3:
singleDigits[x] = "Three, ";
x += 1;
break;
case 4:
singleDigits[x] = "Four, ";
x += 1;
break;
case 5:
singleDigits[x] = "Five, ";
x += 1;
break;
case 6:
singleDigits[x] = "Six, ";
x += 1;
break;
case 7:
singleDigits[x] = "Seven, ";
x += 1;
break;
case 8:
singleDigits[x] = "Eight, ";
x += 1;
break;
case 9:
singleDigits[x] = "Nine, ";
x += 1;
default:
singleDigits[x] = "Unknown ";
x += 1;
break;
}
for ( ; x > 0; --x)
printf("%s", singleDigits[x]);
}
}
Do I get the ubiquitous error:
main.m:24: warning: assignment makes integer from pointer without a cast
for every line that tries to assign a string to the array at index x?
I have trolled the forum to try to understand this error and the nearest I came to was the right side of the = is returning an int and the left side is expecting a pointer?
I am having on going problems trying to assign simple strings to what has to be char arrays??
thanks in advance