473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

seven strings sort

19
Hi if your here to help thanks in advance. My problem is I'm writing a code to take seven strings put in by the user sort them alphabetically than print them, but I my compiler is telling me strcmp command is wrong so I cant compile it and I am sure their are other things wrong please help.

[CODE}

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

# define N_STRINGS 7

void swap(char *, char *);

void strcmp(char *, char *);

int main (void)
{
char w[N_STRINGS];
char i, j, result;

scanf("%s", w);
for (i = 0; i < N_STRINGS; ++i)
{
for (j = i + 1; j < N_STRINGS; ++j)
result = strcmp(w[i], w[j]);
if( result < 0 )
swap(&w[i], &w[j]);
printf ("%s",w[j]);
}
return 0;

}


void swap(char *p, i *q)
{
int tmp;

tmp = *p;
*p = *q;
*q = tmp;
}

[/code]
Sep 25 '08 #1
1 1170
gpraghuram
1,275 Expert 1GB
Why r u declaring the the strcmp function in your code when you have included string.h.
And your strcmp declartaion is wrong as strcmp returns integer and its not void.

Thanks
raghu
Sep 25 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Al Newton | last post by:
I want to use STL's sort algorithm to sort a string vector. Some of the strings are fairly long (300 to 400 chars) and the vector isn't small (5,000 to 10,000 elements). Naturally, sorting time...
3
by: amber | last post by:
Hello, Is there a simple way to sort a listbox that contains strings that are numbers? My listbox is populated from a database field that has a datatype of string, but typically contains numbers....
2
by: qazmlp | last post by:
I have got the following strings: 121721234567890 13 1217212345 129 Is it possible to do descending sort for these strings based on their numeric values? After sorting, they need to figure...
3
by: Daniel Weinand | last post by:
hello ng, i have a problem and a imho an insufficient method of solution. strings should be sorted by specific text pattern and dispayed in groups. the strings are stored in a db and have the...
25
by: Rainmaker | last post by:
Hi, Can anyone tell me an efficient algorithm to sort an array of strings? Keep in mind that this array is HUGE and so the algorithm should me efficient enough to deal with it. Thanks
14
by: manstey | last post by:
Hi, Is there a clever way to see if two strings of the same length vary by only one character, and what the character is in both strings. E.g. str1=yaqtil str2=yaqtel they differ at str1...
19
by: pkirk25 | last post by:
I wonder if anyone has time to write a small example program based on this data or to critique my own effort? A file called Realm List.html contains the following data: Bladefist-Horde...
2
by: gonzo | last post by:
So I have a project where I'm supposed to have a .txt input file of no more than ten first names, last names and birth years, and than in a menu I'm to give the user some options as to how the...
4
by: CoreyWhite | last post by:
/* WORKING WITH STRINGS IN C++ IS THE BEST WAY TO LEARN THE LANGUAGE AND TRANSITION FROM C. C++ HAS MANY NEW FEATURES THAT WORK TOGETHER AND WHEN YOU SEE THEM DOING THE IMPOSSIBLE AND MAKING...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.