Share on Google+Share on Google+

Victor
C language-qsort and bsearch function
1 Answer(s)      7 years ago
Posted in : Ajax

Ads

View Answers

December 5, 2009 at 4:10 PM


Hi Friend,

bsearch function()

#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <conio.h>

char alpha[] = {'a','b','c','d'};
int comp(const void *ch, const void *s);

int main(void) {
char ch;
char *p;

printf("Enter a character: ");
ch = getchar();
ch = tolower(ch);
p = (char *) bsearch(&ch, alpha, 26, 1, comp);
if(p) printf(" %c is in alphabet\n", *p);
else printf("is not in alphabet\n");
getch();
return 0;
}
int comp(const void *ch, const void *s) {
return *(char *)ch - *(char *)s;
}

Thanks









Related Tutorials/Questions & Answers:
C language-qsort and bsearch function - Ajax
C language-qsort and bsearch function  Explain qsort and bsearch function doing examples with character array.please also answer my previous question on main()parameters.thanks.  Hi Friend, bsearch function
bsearch() function in C
bsearch() function in C Programming Language This section demonstrates the use bsearch() function in C. This searches function the given key in the array... the character array. To perform the search, the bsearch() function compares the elements
Advertisements
C/C++/JAVA Question on function
C/C++/JAVA Question on function  "Write a function to find out common... other data type also.ΓΆβ?¬Β? Question can be solved in C,C++ or JAVA. (Recommneded - C
example of function overriding in c++
example of function overriding in c++  require an example of function overriding in c
Function pointer in c
Function pointer in c  What is the difference between function call with function pointer and without function pointer(normal function call
function overloading in c
function overloading in c  are int func1(int x, int y) and void func1(int x, int y) overloaded? can the functions with same name same arguments but different return types be overloaded
C file fsetpos() function
C file fsetpos() function This section demonstrates the use of fsetpos() function in C. The function fsetpos() is used to set the position of the stream... from the function fgetpos(). Its syntax is: fsetpos(File *stream,const fpos_t
C file fseek() function
C file fseek() function This section demonstrates the use of fseek() function in C. This function sets the file position indicator for the stream pointed... with an example. In the following code, the function fopen(file, "w"
C Pointer to a function
; function in C. C provides a special feature of  pointer to a function. As you know  that every function defined in C language have a base address... C Pointer to a function   
java equivalent of c function htonl & htons
java equivalent of c function htonl & htons  hi is there any java equivalent for the c function htonl & htons
Main function parameter in C language - Ajax
Main function parameter in C language  Please let me know how...; Hi Friend, int main(int argc, char **argv) The main function serves.... The fgetpos function gets the current value of the stream argument?s file
How ro convert char into string using recursive function in c#??
How ro convert char into string using recursive function in c#??  This coding is for java...but i want this in c# How ro convert char into string using recursive function in c#?? char [] ch={'H','E','L','L','o'}; TO ans
C file fgetpos() function
C file fgetpos() function This section demonstrates you the use of fgetpos() function. This function get the current read/write position of stream and stores...() function to return to the same position. Its syntax is: fgetpos(File *stream
c++
c++  write a prgrm tht accepts 3 integer values,then with a function to swap the values
c++
c++  .write a program that accepts 5 subjects of a student,it should have a function to calculate the average & another function to grade.grade should be as follows-<40=E,40-49=D,50-59=C,60-69=B & >70
c++
c++  .write a prgrm tht accepts 5 subjects of a student,it shld hv a function to calculate the average & another function to grade.grade shld be as follows-<40=E,40-49=D,50-59=C,60-69=B & >70
c++
c++  Consider the following function: int funcExercise7(int list[], int size) { int sum = 0; for (int index = 0; index < size; index++) sum = sum + list[index]; return sum
c++
c++  write a prgrm tht calculates the surface area of a cylinder.the prgrm shld find the circumfrance and have a function that calculates the fadius and another to calculate the surface area
c++
c++  Consider the following declarations: class xClass { public: void... private members does class xClass have? c. How many constructors does class xClass have? d. Write the definition of the member function func so that u is set to 10
c++
c++  Consider the following declarations: class xClass { public: void... private members does class xClass have? c. How many constructors does class xClass have? d. Write the definition of the member function func so that u is set to 10
function
function  difference between function overloading and operator overloading
c#
c#  how to find out the size of the BMP image in C
C++
C++  How can i write this in dev c
C++
C++  How can i write this in dev c
c++
c++  use a prgrm as an example to xplain-: a)class b)object c)message d)cope resolution operator
c#
c#  how to find out the size of the BMP image
c++
c++  write a programme that calculates the area and circumference of a rectangle
C++
C++  dear sir How to create windows form application for login screen using C++? USER Name -TESTADMIN Password -testuser
c++
c++  i use turbo c++...i want to change the background color...what is the command for it and the header file used
c++
c++  i use turbo c++...i want to change the background color...what is the command for it and the header file used
c++
c++  i use turbo c++...i want to change the background color...what is the command for it and the header file used
Tutorials   
Java Spring Hibernate Struts Training Ajax java How to cascade two text boxes?? How to create runtime drag and drop form builder using asp.net mvc and jquery jsp+ajax validation JQuery-JSP AJAX example not working What is Ajax Framework How to write first example in Ajax? What are Advantages and Disadvantages of AJAX What is Ajax? how to set running watch with descending order in applycation with ajax how to set running watch with descending order in applycation with ajax jsp pages for dispatchaction for adding user to database c++ new, delete, string class using ajax i want to insert data into oracle database how to generate reports from oracle database using jsp and ajax code dynamic creation of multiple drop-down menus Ajax programming tutorials Displaying data from combobox on the web page Displaying data from combobox on the web page Displaying data from combobox on the web page Displaying data from combobox on the web page Displaying data from combobox on the web page What is Java? How to make a ajax application which take data from textarea and that page is not refreshing. how can add new line character into ajax response for java how can add new line character into ajax response for java c# c# asp.net Struts 2 + Ajax bodygaurd java Ajax mew 333 data insertion and fetch 1 my answer what is an ajax call? what is an ajax call? JSF How to easily send and receive recorders from database (in AJAX)? calculating time difference for manually entered in-time and out-time in hours and min for dynamically generated rows in jsp and display in third textfield. how to operate on select box using ajax in struts2? how to operate on select box using ajax in struts2? Auto Search box using ajax Dependant Dropdown Lists AJAX REGISTRATION FORM ajax code for jsp java i want to know how a slide will hide i want to know how a slide will hide

Ads

 
Advertisement null

Ads