help:D

Recommended Answers

All 8 Replies

Posting on the C forum might be a good start.
As would posting more than "help" as the body of your text.

You write a shell the same way you write any other application program; it just happens to be the one which gets automatically loaded after the OS has finished booting. Of course it needs to be able to do useful things such as execute other programs.

Otherwise, it is just the normal interactive loop: Get a command from the user, do whatever is necessary, get a command from the user, do whatever is necessary, get a command from the user.....

i dont think that command intrepreter need to be loaded after the os starts.

its just an application progam..which can execute other programs..dats it..!!!

typing a external command and pressing enter means double clicking it on mouse!!!!

char prompt = '$';
void Lookup( char * cmd );

void main ( void )
{
      char *entry;
      while ( true )
      {
             printf("%c ",prompt);
             scanf("%s",entry);
             Lookup( entry );
      }
}

Jeez, another thread digger who should have stayed quiet. Though somewhat remarkably, code tags have been used on the first post - I'm intrigued....

Anyway, onto the faults - there's one for almost every line.
> void main ( void )
Sorry to burst your bubble, but ANSI-C requires main to return an int.
Sloppy books and compilers don't count as references.

> char *entry;
Erm, where is this pointing?
Not at anything you can be sure of!

> while ( true )
true isn't a C keyword, and you haven't declared it.

> printf("%c ",prompt);
In the absence of a newline, or a call to fflush(stdout), there is no reason to believe the user would even see a prompt.

> scanf("%s",entry);
Not to mention the fact that entry is uninitialised, you don't have any control over how much data gets input by the user. They could type in "war and peace" as a long string, then where would you be?

#include <stdio.h>

char prompt = '$';
void Lookup( char * cmd );

int main()
{
      char *entry = NULL;
      while ( 1 )
      {
             printf("%c ",prompt);  // tried this before
             entry = scanf();  // not sure of this
             Lookup( entry );
      }
      return 0;
}

.. can you be "less" aggressive,

Why? This thread has been dead for months. We could have given you an infraction instead for resurrecting a dead thread and for giving an answer to someone's homework question -- IOW cheating. Consider yourself lucky.

> entry = scanf(); // not sure of this
*faints*

Are you even trying the code before you post it? Or even read the manual pages / tutorials?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.