User Profile

Collapse

Profile Sidebar

Collapse
mosullivan
mosullivan
Last Activity: Nov 21 '07, 06:35 AM
Joined: Nov 13 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • mosullivan
    started a topic Alphabetical sort using strcmp question
    in C

    Alphabetical sort using strcmp question

    I had to write a program that would accept 7 strings through scanf, list the strings, alphabetize, and relist. I was supposed to use strcmp to assist with the sort and write it so that it can sort on a different number by only changing the N_STRINGS 7. So, I've written the program and of course it's not working I admit that the pointers to strings and arrays confuse me. Can someone point me in the right direction? I would appreciate any help!...
    See more | Go to post

  • mosullivan
    replied to Function argument error?
    in C
    I started over and have completed the assignment. Thanks for all your help....
    See more | Go to post

    Leave a comment:


  • mosullivan
    replied to Function argument error?
    in C
    The mess are the two functions. I guess I should have titled them so I didn't cause any confusion. I'll look at total again. Thanks...
    See more | Go to post

    Leave a comment:


  • mosullivan
    replied to Function argument error?
    in C
    Ok, I understand that. I've changed it so that count is a function and now I'm getting an error that says 'lo' is an undeclared identifier. Both hi and lo are identified in the main - is there something I'm missing?

    Code:
    #include <stdio.h>
    
    int total(int hi);
    int count(int hi, int lo);
    
    int main (int)
    {
    	int n;		/*Input by the user*/
    	int m;		/*Input by the user*/
    ...
    See more | Go to post

    Leave a comment:


  • mosullivan
    started a topic Function argument error?
    in C

    Function argument error?

    I don't know where the problem with my program is. I keep getting an error that says the function doesn't take 1 argument. I have two arguments listed for the function everytime I mention it. The error is said to be in line 46. Any help would be great.

    Code:
    #include <stdio.h>
    
    int total(int hi, int count);
    
    int main (int)
    {
    	int n;		/*Input by the user*/
    	int m;		/*Input
    ...
    See more | Go to post

  • Thanks so much for your help. I started completely over and used a print array function and it worked. (Big sigh!)
    See more | Go to post

    Leave a comment:


  • I've moved my printf statements down to between the end brackets (lines 53 - 55) and it prints the final sort. Below is my swap function. Sorry I forgot it - I'm getting pretty stressed over this.


    Code:
     (C) #include <stdio.h>
    
    int swap(int *i, int *j)
    {
    
    
    int tmp;
    
    				tmp = *i;
    				*i = *j;
    				*j = tmp;
    			
    return 0;
    ...
    See more | Go to post

    Leave a comment:


  • Here is what I have now. It will print the "After pass %d:" line the correct number of times but everytime the array is the same.

    [CODE=c]
    #include <stdio.h>
    #define MAXWORD 101
    int swap(int *i, int *j);

    int main(void)
    {
    int sort[MAXWORD];

    int size;
    int i;
    int j;
    int pass = 0;


    printf("Enter how...
    See more | Go to post
    Last edited by Ganon11; Nov 16 '07, 03:43 PM. Reason: Fixing [CODE] tags.

    Leave a comment:


  • I changed a few things and am now able to count each time through the loop and print that back out the appropriate number of times but the array is the same every time. How do I display the contents of the arrary after each pass?
    See more | Go to post

    Leave a comment:


  • mosullivan
    started a topic Printing after every pass through a bubble sort
    in C

    Printing after every pass through a bubble sort

    I can't figure out how to print after every pass through the bubble sort. I'm supposed to display the sort after every pass through the loop. Below is what I have so far.

    [CODE=c]
    #include <stdio.h>
    #define MAXWORD 101
    void swap(int *i, int *j);

    int main(void)
    {
    int sort[MAXWORD];
    int size;
    int i = 1;
    int j;
    int pass = 0;

    printf("Enter...
    See more | Go to post
    Last edited by Ganon11; Nov 16 '07, 02:16 PM. Reason: Fixing [CODE] tags.

  • mosullivan
    replied to Displaying an Int as a string?
    in C
    Thanks. I used the if else and it worked....
    See more | Go to post

    Leave a comment:


  • mosullivan
    started a topic Displaying an Int as a string?
    in C

    Displaying an Int as a string?

    Is there anyway to convert a variable of data type int to a word or constant character in c?

    I'm working on a problem where there was a data type created and the words paper, rock, and scissors are now 0, 1, and 2. I need to printf what was chosen and because the player/machine choices are now represented as integers I don't know how to actually print paper, rock or scissors.
    See more | Go to post
No activity results to display
Show More
Working...