Program help!! 
Author Message
 Program help!!

This is a C program not C++.

I have about 5 tests to take this week and also need to write a simple
program that will have a user enter a string then sort those in alphabetical
order.  For example the output would be

Enter a string please:

hi How are you today

are hi How today you

If anyone could post some code for me I would truely appreciate it, I just
have no time to do this.

Thanks so much.



Sat, 12 Feb 2005 04:30:54 GMT  
 Program help!!

Quote:

> This is a C program not C++.

> I have about 5 tests to take this week and also need to write a simple
> program that will have a user enter a string then sort those in alphabetical
> order.  For example the output would be

> Enter a string please:

> hi How are you today

> are hi How today you

> If anyone could post some code for me I would truely appreciate it, I just
> have no time to do this.

> Thanks so much.

I guess its a little too late for this, but here are some good resources:

http://www.unc.edu/depts/unc_caps/TimeMgnt.html
http://slc.otago.ac.nz/studyskills/ch1sect4.asp

--Aaron



Sat, 12 Feb 2005 04:57:51 GMT  
 Program help!!
Yeah I don't manage my time well at all.  I wasn't actually looking for a
full program just some helpful hints to make it easier on me.


Quote:

> > This is a C program not C++.

> > I have about 5 tests to take this week and also need to write a simple
> > program that will have a user enter a string then sort those in
alphabetical
> > order.  For example the output would be

> > Enter a string please:

> > hi How are you today

> > are hi How today you

> > If anyone could post some code for me I would truely appreciate it, I
just
> > have no time to do this.

> > Thanks so much.

> I guess its a little too late for this, but here are some good resources:

> http://www.unc.edu/depts/unc_caps/TimeMgnt.html
> http://slc.otago.ac.nz/studyskills/ch1sect4.asp

> --Aaron



Sat, 12 Feb 2005 05:04:07 GMT  
 Program help!!

Quote:

> This is a C program not C++.

> I have about 5 tests to take this week and also need to write a simple
> program that will have a user enter a string then sort those in alphabetical
> order.  For example the output would be

> Enter a string please:

> hi How are you today

> are hi How today you

> If anyone could post some code for me I would truely appreciate it, I just
> have no time to do this.

> Thanks so much.

Hi.

While we welcome questions related to homework programs...

WE DON'T DO YOUR HOMEWORK FOR YOU.

You write code, we critique it.

-Micah



Sat, 12 Feb 2005 05:05:17 GMT  
 Program help!!

Quote:

> Yeah I don't manage my time well at all.  I wasn't actually looking for a
> full program just some helpful hints to make it easier on me.

In that case, I suggest you look at strtok().  I would loop over my
string, pull out each token into an array.  Make a new string, and
strcat() each of the tokens into the new string.

--Aaron

Quote:




>>>This is a C program not C++.

>>>I have about 5 tests to take this week and also need to write a simple
>>>program that will have a user enter a string then sort those in

> alphabetical

>>>order.  For example the output would be

>>>Enter a string please:

>>>hi How are you today

>>>are hi How today you

>>>If anyone could post some code for me I would truely appreciate it, I

> just

>>>have no time to do this.

>>>Thanks so much.

>>I guess its a little too late for this, but here are some good resources:

>>http://www.unc.edu/depts/unc_caps/TimeMgnt.html
>>http://slc.otago.ac.nz/studyskills/ch1sect4.asp

>>--Aaron



Sat, 12 Feb 2005 05:08:24 GMT  
 Program help!!
I totally understand that, I didn't make myself as clear as I should have.
What I really need to know is how to get a string to be entered into an
array.

int main()
{
  int i=0;
  char array[50];
  char array2[50];

printf("Please enter a string to be sorted: ");

// I need a while statement that use scanf to put each word(or whatever is
entered) into the array, but I keep getting segmentation faults
// also it need to keep reading in until the enter key is pressed and I
don't know how to do that eiterh

also how do I use the built in qsort to sort items in array

Quote:
}



Sat, 12 Feb 2005 05:17:13 GMT  
 Program help!!


Wed, 18 Jun 1902 08:00:00 GMT  
 Program help!!
I think I got how to sort this array, but I am just really confused on how
to enter these into an array from the keyboard.

So if someone enters the following :        hi how are you

I want it to start enter those into the array when the user presses the
enter key.  If I can figure that out, then I know how to sort that array I
think.

So if anyone could help on that issue I would greatly be appreciated.

The following will not work.  The reason i have 50 there is for a max of 50
tokens.
  char array[50];
  char array2[50];
  printf("Please enter a string to be sorted: ");

while(array[i] !='\n')
    {
      scanf("%10s",array[i++]);
    }



Sat, 12 Feb 2005 05:28:41 GMT  
 Program help!!


Wed, 18 Jun 1902 08:00:00 GMT  
 Program help!!

Quote:

> This is a C program not C++.

> I have about 5 tests to take this week and also need to write a simple
> program that will have a user enter a string then sort those in alphabetical
> order.  For example the output would be

> Enter a string please:

> hi How are you today

> are hi How today you

> If anyone could post some code for me I would truely appreciate it, I just
> have no time to do this.

    Use existing library functions to do most of the work
for you.  Untested, and with error-checking omitted for
brevity:

        #include <stdio.h>
        #include <string.h>
        typedef int (*comp)(const void*, const void*);
        void main() {
            char buff[50];
            printf ("Enter a string please: ");
            fflush (stdin);
            scanf ("%s", buff);
            qsort (buff, sizeof(buff), sizeof(char), (comp)strcmp);
            for (int i = 0;  i < sizeof(buff);  ++i)
                printf ("%s ", buff[i]);
            putchar (10);
        }

--



Sat, 12 Feb 2005 05:09:44 GMT  
 Program help!!

Quote:

> If anyone could post some code for me I would truely appreciate it, I just
> have no time to do this.

Us doing your homework for you is not help at all. You will either need
to make time to do this assignment and learn what it is designed to
teach or take the lumps for it.

Brian Rodenborn



Sat, 12 Feb 2005 05:31:36 GMT  
 Program help!!
I don't want anyone to do my homework for me. Here is my program that is not
working:  I should have posted it earlier.

As i mentioned above what i want to happen and it is not happening.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void sort(char *array[], int size)
{
  char *temp;
  int i, j;

  for (i=0;i<size;i++)
    for(j=0;j<size;j++)
      if (strcmp(array[i],array[j])<0)
 {
   temp=array[i];
   array[i]=array[j];
   array[j]=temp;
 }

Quote:
}

main()
{
  int i=0;
  char *array[10];
  printf("Please enter a string to be sorted: ");

  while(array[i] !="\n")
    {
      scanf("%s",array[i++]);
    }

 num=i+1;
  sort(array,num);

  while(i!=0)
    {
      printf("%s",array[i]);
      i--;
    }

Quote:
}



Sat, 12 Feb 2005 05:58:17 GMT  
 Program help!!

    Moron> This is a C program not C++.  I have about 5 tests to take
    Moron> this week and also need to write a simple program that will
    Moron> have a user enter a string then sort those in alphabetical
    Moron> order.  For example the output would be

    Moron> Enter a string please:

    Moron> hi How are you today

    Moron> are hi How today you

    Moron> If anyone could post some code for me I would truely
    Moron> appreciate it, I just have no time to do this.

I solved this problem some time ago.

http://groups.google.com/groups?q=cwilbur+perl+nicely&hl=en&lr=&ie=UT...

HTH, HAND.

Charlton



Sat, 12 Feb 2005 05:59:30 GMT  
 Program help!!


Wed, 18 Jun 1902 08:00:00 GMT  
 Program help!!
My original message when I said "If anyone could post some code for me I
would truely appreciate it, I just
have no time to do this."  I was refering to how to accept the enter key, I
had orignally wrote that but was cutting and pasting and forgot to put that
wordiing back in.  I just wanted the keyword or whatever to reconize the
user pressing the "ENTER" key.


Sat, 12 Feb 2005 06:01:07 GMT  
 
 [ 33 post ]  Go to page: [1] [2] [3]

 Relevant Pages 

1. Programming Help

2. Program Help for Newbie

3. programming help

4. C Program help please!

5. linux Loadable kernel module programming help!!!!!!!

6. C Programming Help

7. hailstones program, help please

8. C Programming...HELP!

9. How to execute one file from another C program HELP

10. Array Question: Revisited - Specific Program Help

11. socket programming--help please

12. Search Program help?

 

 
Powered by phpBB® Forum Software