Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fortune command #24

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Added fortune command #24

wants to merge 6 commits into from

Conversation

calebrwalk5
Copy link

The fortune command is a fortune cookie, it picks random silly quotes


void ksh_fortune() {
const char fortunes[3] = {"Pohl's Law: Nothing is so good that somebody, somewhere, will not hate it.", "You either die a smart fella, or live long enough to become a fart smella", "Everyone asked you about your favorite dinosaur as a kid, now, nobody cares", "Even stock traders want to arrest hatred", "Generically, fiery liquors that produce madness in total abstainers.", "Our remedies oft in ourselves do lie,? Which we ascribe to heaven.", "One of the most conspicuous qualities of a man in security."};
kprintc("\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// You are passing a "string" on line 6, 8 and 9 as parameter, but kprintc() only accepts 'char'. If you want to print strings, use kprints(), defined in kernel/io.h.

Added the new $fortune command to ListOfOwnCmds
Copy link
Owner

@GandelXIV GandelXIV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use display.kprintc() to print chars, and io.kprints to print string.
Also we dont have a random generation library, so no rand() function.
Had to do some tweaks to make it work.

void ksh_fortune() {
const char fortunes[3] = {"Pohl's Law: Nothing is so good that somebody, somewhere, will not hate it.", "You either die a smart fella, or live long enough to become a fart smella", "Everyone asked you about your favorite dinosaur as a kid, now, nobody cares", "Even stock traders want to arrest hatred", "Generically, fiery liquors that produce madness in total abstainers.", "Our remedies oft in ourselves do lie,? Which we ascribe to heaven.", "One of the most conspicuous qualities of a man in security."};
kprintc("\n");
int RandIndex = rand() % sizeof(fortunes);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// We write all libraries from scratch, so no rand() function is available. You will need to write a rand.c and rand.h file in lib/.

Copy link
Owner

@GandelXIV GandelXIV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@calebrwalk Should i close this pull request?

const char fortunes[3] = {"Pohl's Law: Nothing is so good that somebody, somewhere, will not hate it.", "You either die a smart fella, or live long enough to become a fart smella", "Everyone asked you about your favorite dinosaur as a kid, now, nobody cares", "Even stock traders want to arrest hatred", "Generically, fiery liquors that produce madness in total abstainers.", "Our remedies oft in ourselves do lie,? Which we ascribe to heaven.", "One of the most conspicuous qualities of a man in security."};
kprintc('\n');
int RandIndex = rand() % sizeof(fortunes);
kprints(arrayNum[RandIndex]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// What variable is arrayNum? You have not declared it in this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants