C tutorials for a beginner
I have a problem with thsi code.
this is the result:
bold means my input. when there's a space in the name, it takes it as the age...
this is the result:
[Session started at 2005-09-11 19:40:41 -0700.]
What is your name? [b]Matthew Liebrich[/b]
How old are you? Your name is Matthew, and you are Lie years old.
Executable â€œTesting codesâ€ has exited with status 0.
couls someone post a small program that would just show images? if you do, please include the image files! i just want to see which commands and such are needed. maybe a keyboard input code too?
Tyaedalis Wrote:when there's a space in the name, it takes it as the age...
That's the way scanf works. Read the man pages on scanf for all the gory details:
type man scanf in a terminal
Tyaedalis Wrote:couls someone post a small program that would just show images? if you do, please include the image files! i just want to see which commands and such are needed. maybe a keyboard input code too?
This kind of stuff is not for beginner C programmers. Stick to text only programs for the moment if you want to learn C. If you want to jump right into high-level stuff, start with a higher level language like objective-C, Ruby, Python, or Lua. That said, you may want to check out SDL. It's a C library which simplifies these tasks.
I'd strongly suggest learning objective-C + Cocoa if you're in a hurry to do such high level things (on the Mac, anyway).
yeah, i want to learn objective-c+cocoa. and SDL can work with objective-c, too right?
Tyaedalis Wrote:yeah, i want to learn objective-c+cocoa. and SDL can work with objective-c, too right?
Yes, you can get SDL to work with objective-C... but why? One of the main advantages of SDL is that it's cross-platform (as opposed to Cocoa, which is pretty much Mac-only). About the only thing Cocoa doesn't give you is a simplified HID input (joystick/gamepad) API. Cocoa by itself should have everything you need at the moment.
THE best book on Cocoa is Aaron Hillegass' "Cocoa Programming for Mac OS X".
Also be sure to read some of the tutorials on Cocoa Dev Central.
ok. i will. but what do you think i could make better on my current program?
do you mean "how can I fix the spacing bug?", or do you mean "what other features could I add to my program to get me practising C?"?
You could always use fgetc to get the input 1 character at a time until you reach a new line for the name.