How do I get a string to output a letter instead of a vaule in borland???
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]);
Last edited by Adak; 02-06-2009 at 03:44 PM.
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")
Last edited by geekrockergal; 02-07-2009 at 04:37 AM.
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);
Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
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); }
Im new to C so I make a lot of beginners mistakes !!!
Thanks to everyone for helping, Im must be really annoying you *bangs head on desk*