What would you like to do?

Can you write a function similar to printf?

already exists.

Would you like to merge this question into it?

already exists as an alternate of this question.

Would you like to make it the primary and merge this question into it?

exists and is an alternate of .

//program for myprintf using variable arguments
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
int compare(const void * var1,const void * var2)
{
if(*(int *)var1 > *(int *)var2)
{
return(0);
}
else{
return(1);
}
}

int myPrintf(const char * output ,...)
{
va_list arguments;
int stringlength,stringIndx;
char *s;
int d;
char c;
stringlength = strlen(output);
va_start(arguments,output);
for(stringIndx = 0;stringIndx < stringlength;stringIndx++)
{
if(output[stringIndx] == '%')
{
stringIndx++;
switch(output[stringIndx])
{
case 's': /* string */
s = va_arg(arguments, char *);
printf("%s\n", s);
break;
case 'd': /* int */
d = va_arg(arguments, int);
printf("%d\n", d);
break;
case 'c': /* char */
default:
/* need a cast here since va_arg only
takes fully promoted types */
c = (char) va_arg(arguments, char);
printf("%c\n", c);
break;
}
}
else{
printf("%c",output[stringIndx]);
}
}
}
void main()
{
unsigned int au32Nos[10] = {32,44.,55,66,11,8,9,7,9,10};
qsort(au32Nos,10,4,compare);

myPrintf(" %d %d %d %d %d %d %d %d %d %d",au32Nos[0],au32Nos[1],au32Nos[2],au32Nos[3],au32Nos[4],au32Nos[5],au32Nos[6],au32Nos[7],au32Nos[8],au32Nos[9]);
}
Thanks for the feedback!

Similarity of function between starch and protein?

both can be sources of energy, starches are easily broken down, or digested, into energy sources primarily carbohydrate (sugar) chains. Proteins can be used for energy also, b

What is use of printf?

printf() is a build-in function under the header file 'stdio.h' in a C programming language. In c++,the same function is accomplished by 'cout' . It is used to display strings

How is the function of NAD similar to NADP?

They both are types of organic molecules and both accept molecules during redox reactions,(shorthand for reduction-oxidation reaction).A redox reaction describes all chemical

What does printf and scanf return?

Printf returned no. of character receive .   scanf return no of variable to be inputed according to format specifier .   eg:   i=printf("thisisc")   printf("%d

Are personal and academic writing similar?

In some ways they are similar. Both personal and academic writing is aimed at an audience. The academic writer for his fellow academics and the personal writer to whomever the

What are the Similarities of descriptive writing and narrative writing?

They are similar because they both tell you something. Descriptive writing describes--so it's going to tell you how something looks, how a person walks into the room, what tha