How do I get a string to output a letter instead of a vaule in borland???
Printable View
How do I get a string to output a letter instead of a vaule in borland???
what?
Code:char var = 'A';
printf("%c", var); //not d
//or
int i;
char string[] = { "How far to Andromeda?" };
stringLength = strlen(string);
for( i = 0; i < stringLength + 1; i++)
printf("%c", string[i]);
thanks Adak
so if I wanted to create a program that outputted a letter that the user inputted, would it look like this:
if that is true say I want the user to input a speific letter, would it look like this:Code:printf ("Please input letter: ");
int %c
printf ("The letter you have inputted is: "%c);
Code:printf ("Please input letter: ");
int X=A
int X=B
if X=A printf ("The letter you have inputted is A")
if X=a printf ("Please input letter in captials")
if X=B printf ("The letter you have inputted is A")
if X=b printf ("Please input letter in captials")
So... if you want to create a program that output a letter that the user inputted you can do smthg like this:
You can do this in many other ways.Code:char letter;
printf ("Please input letter:\n");
do {
letter = getch();
printf ("\nThe letter you have inputted is: ");
putch(letter);
}
while (letter != 27);
geekrockergal, you need to hit the books or tutorials to understand the basic syntax of C before proceeding.
I see. Well, you have a lot to learn still.
Good luck with your studies then.
so is it possiable to do this (I want the user to input a speific character A or B)
Im sorry people I really am trying my hardest to get my head around thisCode:char letter;
printf ("Please input letter:\n");
if {
letter = getch(A);
printf ("\nThe letter you have inputted is: A ");
putch(letter);
}
else{
letter = getch(a);
printf ("\nPlease input a captial A ");
putch(letter);
}
if {
letter = getch(B);
printf ("\nThe letter you have inputted is: B ");
putch(letter);
}
else{
letter = getch(b);
printf ("\nPlease input a captial B ");
putch(letter);
}
If WHAT? If you have an if, then you have then what, too, no?Code:if {
getch takes 0 arguments.