untouchablecuz
Active Member
- Joined
- Mar 25, 2008
- Messages
- 1,693
- Gender
- Male
- HSC
- 2009
hey guys. i'm not sure how to solve this and if anyone could give me a leg up it would awesome (i don't actually WANT the code for the task, just a tip or something)
what i want to do is identify the number of characters that are inputted into scanf(). what i CAN do is identify the number of numbers etc that are inputted (using x=x+1 type of thing), but that doesnt help me
i.e. i want this:
i want the user to input 17 characters into the program
output: system prints you have inputted 17 characters
in terms of code:
scanf("something something", &something)
if (the number of characters inputted equals to 17) {
printf("17 characters inputted");
} else if (the number of characters inputted equals to 18) {
printf("18 characters inputted");
} else {
printf("Not 18 or 17 characters inputted);
}
in general, how do i count the number of characters inputted?
e.g. system Please enter a random number:
user: 456789
system: This number has 7 characters
(edit: sorry if im abit jumbled up)
what i want to do is identify the number of characters that are inputted into scanf(). what i CAN do is identify the number of numbers etc that are inputted (using x=x+1 type of thing), but that doesnt help me
i.e. i want this:
i want the user to input 17 characters into the program
output: system prints you have inputted 17 characters
in terms of code:
scanf("something something", &something)
if (the number of characters inputted equals to 17) {
printf("17 characters inputted");
} else if (the number of characters inputted equals to 18) {
printf("18 characters inputted");
} else {
printf("Not 18 or 17 characters inputted);
}
in general, how do i count the number of characters inputted?
e.g. system Please enter a random number:
user: 456789
system: This number has 7 characters
(edit: sorry if im abit jumbled up)