C Programming Question - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Skype & Technology (/forumdisplay.php?fid=9) +---- Forum: Tech Talk (/forumdisplay.php?fid=17) +----- Thread: C Programming Question (/showthread.php?tid=51334) C Programming Question by John Anderton on 10-03-2005 at 06:48 PM
I have made a few programs viz the pascals triange (it took me 10 mins to figure out how to print out the numbers in a perfect triangle) and fibonnici series (easy 1 1 2 3 5 8 13 21 34 55) code: Someone please help quick And dz why does the [code] tag parse emotes [/code] RE: C Programming Question by Yousef on 10-03-2005 at 07:03 PM
quote:__toascii(integer) quote:Char character = integer should work I think. RE: RE: C Programming Question by Plik on 10-03-2005 at 07:06 PM
quote: can you just typecast a char to an int to get the ascii value, or is that just in C++? RE: C Programming Question by John Anderton on 10-03-2005 at 07:18 PM
quote:Erm .... im still a c newb if you didnt realise that from my coding style Yeah i know typecasting and all ..... but i dont think you can do it like that ..... Its something like code: usually we say printf("%c",a); but here it should be something like printf("%c",'a'); but that doesnt work ..... and i cant find it in any book quote:Since i havent learned that .... teacher will be suspicious .... still there must be a header file reqd ... what is it .... and whats the syntax .... ill find it in my book or on google i guess RE: C Programming Question by Plik on 10-03-2005 at 07:25 PM
quote:Well you can do it just using code:in C++ but i dont know if you can in C, give it a shot and find out (whats the worst that can happen ) quote:To output a interger as the number value using printf you'd use. code: P.S Dont worry if im wrong i havnt been coding with c for very long either RE: C Programming Question by John Anderton on 10-03-2005 at 07:33 PM
quote:What i meant is that i heard that there is a way to do that whole thing in one printf statement Damn ..... why didnt i write it down Neways ill try that nAscii idea of yours tho im not that hopeful .... if anyone knows about it then help me ..... I got an idea like if i tell the compiler that a variable ( m ) ..... code: Will that work I know i can use the conversion type functions calling "ctype.h" and the using functions like isalpha, isupper and/or islower ..... but thats a different approach cause the question says that i should use the ascii values EDIT: quote: I got that a long time back thanks but keep trying ..... RE: C Programming Question by J-Thread on 10-03-2005 at 08:27 PM
How about code: So if m is a char: code: I don't do C++ but I know a lot of programming languages and this is a method that is sometimes used... RE: RE: C Programming Question by segosa on 10-04-2005 at 06:09 AM
quote: code: code: RE: C Programming Question by John Anderton on 10-04-2005 at 07:45 AM
quote: Yeah now why didnt i think of that .... thanks seg .... i think thats it Thanks RE: C Programming Question by RaceProUK on 10-04-2005 at 10:46 AM
A quick explanation of why it works: code:It gets a character from the keyboard (stdin), and returns it as unsigned. This leaves the negative values of int free for error codes. Put simply: 0-255 is a valid character <0 is an error. Edit: Of course, once you've checked it's positive, you will need to typecast into a char. char is typically 8 bits, int 16/32 bits. |