User Profile
Collapse
-
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!... -
I started over and have completed the assignment. Thanks for all your help.... -
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...Leave a comment:
-
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*/
Leave a comment:
-
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
-
Thanks so much for your help. I started completely over and used a print array function and it worked. (Big sigh!)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;
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...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?Leave a comment:
-
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... -
-
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.
No activity results to display
Show More
Leave a comment: