![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#51 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
If you upgrade a dummies book, is it still a dummies book???
![]()
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#52 | |
|
Programmer
|
Quote:
Okey, i'll do some more coding and then i'll se what the result looks like. I'm not sure if I can get a newer version of the dummies book. The library is kinda slow taking in programming books. funny dawei haha-thondal-
__________________
"die" he screamed at the polygon man. When he was done with him, only four points remained, a quad of what he once was. |
|
|
|
|
|
|
#53 |
|
Programmer
|
DOH!
I just got word from my boss that I'm not allowed to have a compiler on the work-machine that i'm on. He said that when I get my laptop I can do it, but not on this machine... I'm not getting my laptop before 25th of july, because it's a special order, a mix between macintosh and windows and the colour he ordered for me was out. DOH! -thondal-
__________________
"die" he screamed at the polygon man. When he was done with him, only four points remained, a quad of what he once was. |
|
|
|
|
|
#54 |
|
Expert Programmer
Join Date: Dec 2004
Posts: 794
Rep Power: 4
![]() |
A mix between Mac and Windows?!
By the way, if you're work is unrelated to programming, wouldn't your boss have gotten mad at you for using company time to program on the work computer? I hope you weren't badly scolded.
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials. --WilliamSChips on Slashdot |
|
|
|
|
|
#55 | ||
|
Programmer
|
Quote:
![]() Quote:
GO NOTEPAD! By the way is there a way to compile it yourself? -thondal-
__________________
"die" he screamed at the polygon man. When he was done with him, only four points remained, a quad of what he once was. |
||
|
|
|
|
|
#56 |
|
Programmer
|
hey dawei, having some problems. When using fgets, how do i put them in my text so they turn out okey in the output... i got this:
#include <stdio.h>
/* Welcome to Lands End version 0.03.
Author: Simen Skogheim
Copyright: Magical Pictures
Last edited: 7/7 - 2006
*/
int main()
{
char name[25];
char race[15];
char sex[8];
char proffesion[15];
char answer[5];
printf("Welcome to \"Lands End\" rpg game.\n\nTake on the role as a Hero in an ever growing world,\nwhere you can decide the fate of the world you are in.\n");
gets(answer);
printf("The God \"...\" has given you life.\nUse it to promote goodness in this world, be neutral or aid the darkness.\n");
printf("First, what is the name you whish to be known by?\n");
fgets(name, 25, stdin);
printf("Are you Male or Female?\n");
fgets(sex, 8, stdin);
printf("Are you an Elf or Human?\n");
fgets(race, 15, stdin);
printf("Are you, a fighter, mage or ranger?\n");
fgets(proffesion, 15, stdin);
printf("\n\nWelcome to \"Lands end\" %s,\nYou enter this world as a %s %s, and belong to the race of %s.\nYour powers grow as you train, use them wisely...\n",name,sex,proffesion,race);
gets(answer);
printf("\n\nFirst all you see is a bright shining light. Then everything turns dark. \n\nYou can feel your body, but it feels to heavy to move.\nThen, you hear a sound in the distance, almost like mumbling.\nYou concentrate and try to make out the words \n\n");
gets(answer);
printf("\"Hey, are you okey?\" \n\"Can you hear me?\"");
printf("\n\nYou open your eyes and can faintly make out the face of what looks like a %s,\nstanding next to you.",race);
getchar();
return(0);
}but my output on the last gets all wrong... is it the use of the %s? If you can point me to where my mistake is, then I would appreciate it... You don't have to tell what the problem is, just where, I want to fix it myself (helps me learn i guess) -thondal-
__________________
"die" he screamed at the polygon man. When he was done with him, only four points remained, a quad of what he once was. |
|
|
|
|
|
#57 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Well, for one thing, you're still using 'gets'. Slap your own wrist. Toss it in the shit can. Forget you ever heard of it. Secondly, you use it twice in a row for 'answer', which overwrites the previous 'answer', without (apparently) having used it. Thirdly, you don't really describe your failure, just that you have one "on the last gets". Information is key, both in debugging and in eliciting effective answers. It would also be less strenuous on your potential respondents if you didn't require them to scroll from El Paso to Cincinnati to see what variables you are using in your 'printf'. Make a simple example that demonstrates the problem. In other words, shorten that blabber until you have resolved the problem.
Replace the 'gets' with 'fgets', double check your usage of each item, post back with problems.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#58 |
|
Programmer
|
okey here's where the problem lie I guess
printf("\n\nWelcome to \"Lands end\" %s,\nYou enter this world as a %s %s, and belong to the race of %s.\nYour powers grow as you train, use them wisely...\n",name,sex,proffesion,race);the output is as follows welcome to "lands end" thondal , you enter this world as a male mage , and bleong to the race of elf . your powers grow as you train, use them wisely kinda frustrating... -thondal-
__________________
"die" he screamed at the polygon man. When he was done with him, only four points remained, a quad of what he once was. |
|
|
|
|
|
#59 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Come on, man. You show a statement, you say the output is thus and such, but not what it's supposed to be. We can't see what you typed for input. You don't show your rewritten code. Nevertheless, my crystal ball says that what you have is newlines in your input that you didn't remove. Those come from the ENTER key. Some people want them. Fgets reads until the end of file, until the specified maximum number of characters are read, or until it finds a newline. It then terminates the buffer with '\0'. If it maxes out on characters, there won't be a newline. If there's a newline, it'll be the last character in your buffer, at strlen [buffer] - 1. Dump a '\0' there if you want to get rid of it. Man 'fgets'. There's a plethora of information there; all one has to do is read. It also tells you how an error is indicated; don't forget to check.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#60 |
|
Newbie
Join Date: Jun 2006
Location: Vancouver, BC.
Posts: 2
Rep Power: 0
![]() |
Yeah, yeah, so it's so long past the recommendation of material stage, still.
http://www.eskimo.com/~scs/cclass/notes/sx11a.html http://www.crasseux.com/books/ctutorial/ Those two + whatever x terminal (konsole ftw) + vim + gcc got me where I am today. I find books alright when I'm interested in something specific, but when you want to learn how to code or any such thing, they're far too cumbersome. At least for me. Open a terminal, attempt to compile your program, watch it fail, figure out why. Of course, after growing in such an evironment I now find it completely unnatural/limiting to write / compile anything on a non-*nix platform So it's not without its pitfalls. The fault of most online tutorials is they tell you how to do _x but don't even come close to explaining how it works. http://www.eskimo.com/~scs/cclass/ <-- is the most detailed tutorial/course/whatever I've ever found. Check out http://www.eskimo.com/~scs/cclass/notes/sx11a.html to get a guess of the quality. The was also a very humourous article written on pointers, in story form. I wish I could remember the URL. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|