printf() Function- What is the difference between "printf(...)" and "sprintf(...)"?

1 Answer

Answer :

sprintf(...) writes data to the character array whereas printf(...) writes data to the  standard output device.

Related questions

Description : What is the output of printf("%d")?

Last Answer : 1. When we write printf("%d",x); this means compiler will print the value of x. But as here, there is nothing after ï ½%dï ½ so compiler will show in output window garbage value. 2. When we ... an error without the proper number and type of arguments for things like printf(...) and scanf(...).

Description : malloc() Function- What is the difference between "calloc(...)" and "malloc(...)"?

Last Answer : 1. calloc(...) allocates a block of memory for an array of elements of a certain size. By default the block is initialized to 0. The total number of memory allocated will be (number_of_elements * ... calls malloc(...) in order to use the C+ + _set_new_mode function to set the new handler mode.

Description : String Processing --- Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba.

Last Answer : void PrintPermu (char *sBegin, char* sRest) { int iLoop; char cTmp; char cFLetter[1]; char *sNewBegin; char *sCur; int iLen; static int iCount; iLen = strlen(sRest); if (iLen == 2) { iCount++; ... printf("\nEnter a string:"); scanf("%s%*c",sIn); memset(s,0,255); PrintPermu(s, sIn); }

Description : "union" Data Type What is the output of the following program? Why?

Last Answer : #include main() { typedef union { int a; char b[10]; float c; } Union; Union x,y = {100}; x.a = 50; strcpy(x.b,"hello"); x.c = 21.50; printf("Union x : %d %s %f n",x.a,x.b,x.c); printf("Union y : %d %s %f n",y.a,y.b,y.c); }

Description : Linked Lists -- Can you tell me how to check whether a linked list is circular?

Last Answer : Create two pointers, and set both to the start of the list. Update each as follows: while (pointer1) { pointer1 = pointer1->next; pointer2 = pointer2->next; if (pointer2) pointer2=pointer2->next ... before pointer1, or the item before that. Either way, its either 1 or 2 jumps until they meet.

Last Answer : Size of the final executable can be reduced using dynamic linking for libraries.

Description : What is C language?

Last Answer : The C programming language is a standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating system. It has since spread to ... language for writing system software, though it is also used for writing applications. ...

Description : What are the functions of Printf () and Getch () function ?

Last Answer : The most commonly used function as an output statement in C language is printf (), which can be used to display various types of data (such as int, Char, float, etc.), including strings or strings ... programming . That is, both print () and getch () act as essential functions for C programming .

Description : Write a C program Reading and Writing data using Scanf() and Printf() statement -Technology

Last Answer : #include int main(){ char ch; char str[100]; printf('Enter any character '); scanf('%c', &ch); printf('Entered character is %c ', ch); printf('Enter any string ( upto 100 ... , str);}OUTPUT:Enter any characteraEntered character is aEnter any string ( upto 100 character )haiEntered string is hai

Description : printf ("%" d,% x ", & b); Explain the statement ?

Last Answer : printf ( % d,% x , & b); Here , the printf statement displays the output function printf () function as a variable data result of different data types. The C program is used to ... b respectively which indicates the memory location of integer type a and b variables where data will be stored.

Description : What kind of mistake is it to write print f instead of printf and why ?

Last Answer : Write print f instead of printf, the syntax is wrong. If the syntax is wrong then the language in which the program is written is grammatically incorrect. As can be seen , the word Printf ... error. This error is easily detected when translating with a compiler and sends a message to the computer.

Description : State the use of printf( ) & scanf( ) with suitable example.

Last Answer : printf( ) & scanf( ): printf() and scanf() functions are library functions in C programming language defined in stdio.h . printf() function is used to print the character, string, float, integer, octal and hexadecimal ... number"); scanf("%d",&i); printf("Entered number is: %d",i); getch(); }

Description : Trace the error: void main( ) { int *b, &a; *b = 20 printf(“%d, %d”, a, *b) } (A) No error (B) Logical error (C) Syntax error (D) Semantic error

Last Answer : (C) Syntax error

Description : What will be the output of the following segment of the program? main( ) { char *s = “hello world”; int i = 7; printf(“%, *s”, i, s); } (A) Syntax error (B) hello w (C) hello (D) o world

Last Answer : Answer: Marks given to all

Description : How many times the word 'print' shall be printed by the following program segment? for(i=1, i≤2, i++) for(j=1, j≤2, j++) for(k=1, k≤2, k++) printf("print/n") (A) 1 (B) 3 (C) 6 (D) 8

Last Answer : (D) 8

Description : What will be the output of the following ‘C’ code ? main ( ) { int x = 128; printf (“\n%d”, 1 + x++); } (A) 128 (B) 129 (C) 130 (D) 131

Last Answer :  (B) 129

Description : What is the output of the following program ? (Assume that the appropriate pre-processor directives are included and there is no syntax error) main() { char S[ ] = "ABCDEFGH"; printf ("%C",* (& ... Base address of S is 1000 */ } (A) ABCDEFGH1000 (B) CDEFGH1000 (C) DDEFGHH1000 (D) DEFGH1000

Last Answer : (D) DEFGH1000