Hoplite
06-19-2009, 10:26 PM
what is the java equivalent code for the following
char array[5];
printf("enter desired characters: ");
for(i=0;i<5;i++)
scanf("%c",&array[i]);
what i did was i declared a string array, took all the characters (including spaces) in a single string, stored it into the array and removed the spaces...but there has to be a better way, isn't it???
char array[5];
printf("enter desired characters: ");
for(i=0;i<5;i++)
scanf("%c",&array[i]);
what i did was i declared a string array, took all the characters (including spaces) in a single string, stored it into the array and removed the spaces...but there has to be a better way, isn't it???