Sunday, May 10, 2009

What does 'f' represent in "printf" function in C language?

why they used printf instead of print?

What does 'f' represent in "printf" function in C language?
The class of printf functions stands for "print formatted" :)
Reply:As he said there is a family of functions used for formatted output! printf, fprintf, sprintf, etc!





Don't ask me why they made so many! Ask Dennis Ritchie! printf prints to the standard output so it is the most common one!





I even like printf...print is just too common! printf is original...it is elite :p
Reply:print formated.....
Reply:Hi!! f in printf stands for format or formated





At first it may appear that C's basic IO functions look strange compared


to "cin" and "cout". But in fact "scanf" and "printf" are very powerful


tools. The "f" in "printf" and "scanf" stands for "formated". The first


argument to printf is always a string which defines a format. Here's an


example:





int x = 3; int y = 4;


printf("x is %d and y is %d",x,y);

yu gi oh cards

Suggest a definition for printf statement in c?

not just declaration or prototypes..a complete function definition for printf...header files have only declarations...

Suggest a definition for printf statement in c?
hmm, a off handed code that I could come up with..


int printf(const char *format, va_list ap)


{


va_list aq = ap;


va_start();


/* some platform dependent code that will be wrapped under C functions */


increment the counter by one for every character written to stdout.


va_end();


return counter;


}





A rather rough code.. or rather pseudo code.
Reply:Visit http://borland.com this is the only place where you may get desired information
Reply:search for the trio project, it's a string library which implements printf. it's very long and complex.


Can someone explain to me in the simplest form. what is "printf" in C++?

outputs a string on console

Can someone explain to me in the simplest form. what is "printf" in C++?
printf is the command to display text.


for example you want to display "hello", the code is...





printf("hello");
Reply:when you want to display text in screen
Reply:Actually printf is NOT c++, it is c.





As others mentioned it is the command to print a string of data to the standard console (i.e. your monitor). The data can be formatted using special characters delmited by a '%' followed by a specification that allows you to substitute for basic data types (floats, ints, exponents, etc.).





If you are programming in C++ you should be using 'cout' and iostream.
Reply:It is used to format variables for easy reading. For example, you might say:





int iterations = 123;


float seconds = 2.55343;


printf("We looped for %d iterations in %.2f seconds\n", iterations, seconds);





You might get output like





We looped for 123 iterations in 2.55 seconds





That's much easier than trying to do it yourself. In C++ you also have the option of "%26gt;%26gt;" and "%26lt;%26lt;" style instead of printf. They both do much the same thing.
Reply:printf mean you are declaring the action or words on the dos screen in an examp is


#include %26lt;stdio.h%26gt;





int main()


{


printf("hello world\n");


return 0;


}





this is also consiterd a varry small but the warry well known program.by D.R.
Reply:It is used to display text.


What is the difference between stream output and printf in C programming?

'printf' allows for formatting between characters, generally intended for output to the screen or output to a "file" to be printed later.





Stream output is intended for a data file for record retention or further processing like sorting. There are no options for control or format characters.

What is the difference between stream output and printf in C programming?
Stream Output, as you call it, is just a way to say that you want to put data (normally text) into a device. You put the data into a stream that flows to the device and then it does whatever it is designed to do with the data. This applies to anything that can recieve streams of bytes: printers, text or graphical screens, plotters, card punchers (I'm not sure if that's the proper name for that kind of device), etc.





printf is a standart C function who delivers those streams to a device called STDOUT, which is normally the screen of the computer (but can be changed). It has some good things (easy text formatting) and some not so good (memory usage might be a risky thing, as in most C programs, in some situations)
Reply:printf is a function used in language C


But stream output is cout function used in C++


What does f stand for in printf in c programming?

Formatted

What does f stand for in printf in c programming?
Yup... Format just like YFNS said - lets you format the output of the print command
Reply:printf() =print file
Reply:No, not file--it stands for formatted.

thank you cards

How to use printf in c with out ;?

if i want to print india how can i print without using ;

How to use printf in c with out ;?
Try this code





int main()


{


int c = 0;


if (printf("India\n") == 0)


c = 1;


return c;


}





You cannot avoid using ; but you can compare the return value


of printf.
Reply:by using #define


What do printf in c?

a printf statement is a command that simply prints the text you type in. nothing else. you probly want to use a scanf with the printf if you want to ask a question or sumthing like that.





heres and example of a printf.





printf("this is what you will see when you run the program");





its pretty simple.

What do printf in c?
It outputs data to a stream
Reply:printf creates a formatted output to the screen. there a variations, fprintf and sprintf that output to a file or a string. for an example:





int exampleInt = 3;


printf(("Hello exampleInt = %d\n",exampleInt );





outputs


"Hello exampleInt = 3"


the \n is a line feed.
Reply:it prints the text or any thing in c


Where can i find assembly code of c functio like printf(),getchar() etc. ?

is there c code for above c function ?


where can i find ?

Where can i find assembly code of c functio like printf(),getchar() etc. ?
try this link





http://www.cs.wisc.edu/~david/courses/cs...
Reply:Use a search engine to find free downloads of GNU c compilers. They all include the source code for the library functions. Some primitive functions will be written in assembler for various processors. Most functions will be written in c for portability.





An easy place to start would be a free Linux download or a Linux CD. They almost always include a GNU c compiler.
Reply:As the link Joe provided above mentions, the c code for printf() and getchar() etc are all on the header files that come with you c development environment. Find the header files, e.g. stdio.h in this case and you will find your code. Assuming you are on a Linux/Unix or similar system you will most likely find in under /usr/include. If not then install glibc-headers.


The assembly code is something different and will only be available once you have compiled your code. Check utilities like gdb (Gnome debugger (I'm assuming you are on a Linux/Unix or similar system again) that will allow you to step through a program as it runs and see all the code and anything else relevant that is available.


Can we write a function similar to printf() in C Language?

can we write a function similar to printf()


as it should take variable number of arguments and it will show the output on the screen...


if possible please provide the code

Can we write a function similar to printf() in C Language?
Yes. To use a variable number of arguments use %26lt;stdarg.h%26gt;. Once you have that, it's pretty straightforward to send strings to stdout.
Reply:just look at the source of stdio.h u'll find the code,, no big deal
Reply:cprintf
Reply:Try 2 use the (stdout) stream.

potential breakup song

Write a program in c for printf function instead of using printf library function?

I faced this questiuon in hoiney well plz reply anybody

Write a program in c for printf function instead of using printf library function?
#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;





void main()


{


char a[6]={'t', 'a', 'n', 'v', 'e', 'e', 'r'};


int i;


i=0;


while(a[i]!='\o')


{


putchar(a[i]);


}


i++;


getch();


}











compare this with the above program which is without printf function.








void main()


{


printf("tanveer");


getch();


}











Hope this will give you some idea or reference. The question is not asked specific to any integer printing or charter printing.


I have used character printing.
Reply:you can implement the printf() clone in many ways..


One way is to use putchar() method...


now you'll be wondering how to pass random number of arguments to our new function (let it be named myprint())..





In C we can write functions which takes multiple number of arguments...


how??





int myprint(int itemsToPrint, char [] type,...)





So now prototype is done..





We now just need to resolve the arguments which are to be printed.. For this we need to use few macros provided by most of the C implementations..


Using these macros we can access the arguments passed to our new function(i don't remember there name properly...)


Even printf/scanf uses those macro calls..


In our function first argument is the number of arguments to be printed.. Second argument is a character array which must contain the type of arguments which are to be printed in the order of appearance in the function call...





now if you are to print a character / character string using putchar is easy....


if you are about to print a float/int etc.. then convert them to character array and use puthar to print individual characters ...


In C/C++, is printf faster than cout?

Is there a difference in performance between printf and cout





and


scanf and cin. Please Help.

In C/C++, is printf faster than cout?
Cout and printf are both buffered file functions, so neither will be faster. There might be a microscopic lag in printf due to work done by the CPU to format printf, but that should be almost non-existant.


What are .dll files? Are these file get called in the linking process? In C printf() has its prototype in?

stdio.h. Where is the body of the printf()? Is it in the form of dll?

What are .dll files? Are these file get called in the linking process? In C printf() has its prototype in?
DLL = Dynamic Link Library. They do not get called in the linking process, but the equivalent .lib file does. A dll file may contain many functions called from many other programs. They exist to avoid having to have these functions statically linked with (many) programs and thus taking up space. For example, many win32 API functions exist in kernel32.dll.





As for printf, you'll find the body of these functions live in one or another msvcrtxx.dll (microsoft visual c runtime) files. Those are automagically referenced by the linker by means of the equivalent msvcrtxx.lib files, that contain info about the functions in the .dll. Those are used by the linker to resolve links, while the DLLs are used at runtime to provide code.


How do you printf quotation marks " " in C?

I know that to print a message we use printf (" message" );





but how do you print quotation marks? I tried with Dev-C typing printf (" "message" "); it does not work.

How do you printf quotation marks " " in C?
Simple think


In C, since for next line we have the \n, for tab \t, for alarm \a etc, we have \" for including the Double quotes symbol for printing.





Like printf("\" Hello World\"");


will give the output as





"Hello World".
Reply:printf("\"Hello World\"");


:)
Reply:Every language has a way of 'escaping' delimeters. In most implementations of C, this is the backslash. This is not always true so you need to make sure you know the escape characters of the language you happen to be using at the time. Here's how it works in most C compilers.





printf("She said, \"why?\"");





would result in the sentence:


She said, "Why?"
Reply:To print quotation marks you \" the \ tells the c compiler to honor the quotation marks and not to use them as delimiters.
Reply:Hello,





You need to read more about the C language. I suggest to start learning, rather than wasting too much time on figuring out language-dependent stuff.





These links may be helpful:





http://www.imada.sdu.dk/~svalle/courses/...





http://www.acm.uiuc.edu/webmonkeys/book/...





Thanks
Reply:You must have heard of 'Escape Sequences' in programming world. These are special symbols that change the normal meaning of other symbols. In C, a back slash is an escape sequence. For example in C string lower case n means letter n but if you write \n, its meaning is changed to be line feed character. the same case is with \r for carriage return, \t for tab and so on.





So, In C/C++ a double quote has a normal meaning of string delimiter, that is, this symbol tells compiler the start and end of string. So what should we do if we really want to print this character as part of string? Don't worry, here comes the escape sequence \. if your put \ before " it escapes its normal meaning (string delimiter) and tells compiler to take it as a character that is part of string. so





printf("\"London\""); will pring "London"





and





printf("This is a \"Very Good\" idea"); will print This is a "Very Good" idea





Hope that answers the question
Reply:put a slash in front of the double quote like this, \"


In C, you would use slash to escape certain special characters.

love song

C++ help.... printf command?

can anyone please explain me what will the following statement do in c language?





printf("\n Pin 15: %d",(data %26amp; 0x08)/0x08);

C++ help.... printf command?
in c++ the header stdio.h is changed to iostream.h,


printf("---%d",c) is modified to cout%26lt;%26lt;"---"%26lt;%26lt;c


scanf("%d",%26amp;d) is taken as cin%26gt;%26gt;d


that all!
Reply:\n - new line operator


%d - is for printing out integers


data - is a variable


%26amp; - bitwise and operation


0x08 - a hexadecimal number .





So, what i figure is there will be a and operation with data and the hexa number, then a division, then it will be printed out as an integer. If you ask me what for?...then I'll say dunno.
Reply:You can get someone to do your assignment at http://k.aplis.net/


Java printf problem, System.out.printf("%*c", n, ' '); doesn't work?

When I try to format my text by adding n width


i.e System.out.printf("%*c", n, ' ');





with n being the number of spaces, ' ' being the blank space char.





I get the error:





Exception in thread "main" ava.util.UnknownFormatConversionExceptio... Conversion = '*'

Java printf problem, System.out.printf("%*c", n, ' '); doesn't work?
there is no in build method like "printf" in Java. so if you Reilly wants to use it , then you have to write definition for the


printf() method explicitly.
Reply:The problem is printf. This is not a java method.


You should be using System.out.print() or System.out.println().


See the link below for the tutorial on how to use formatting.


Simple error in C; printf function.?

This is probably extremely simple and easy, but I can't figure it out, because I usually program in C++. I am getting this error when compiling:





[Warning] passing arg 1 of `printf' makes pointer from integer without a cast





This is my code I use when I get this error, in my function that prints variables.





void printDate(char date[])


{





int n;


for (n = 4; n %26lt; 6; n++)


{


printf(date[n]);


}


printf("/");


int m;


for (m = 6; m %26lt; 8; m++)


{


printf(date[m]);


}


printf("/");


int i;


for (i = 0; i %26lt; 4; i++)


{


printf(date[i]);


}


printf(" at ");


int z;


for (z = 8; z %26lt; 12; z++)


{





printf(date[z]);


}


}














I have no idea why it's screwing up, but if anyone could help me I'd greatly appreciate it :)

Simple error in C; printf function.?
you need to use something like


printf("%c", date[j])


the %c means a variable of type character


i dont know if this is the exact way but its definately he right structure
Reply:the error sounds like you're passing your date, not the address of the date. Without seeing how you call it, its hard to say.
Reply:For printf()





you need the formatted data and then the arguments








Found something to help you:


http://www.cplusplus.com/reference/clibr...
Reply:printf() definition is


printf(char *, ...)


You are trying to call it as


printf(char) which causes this error


I have updated the code so it uses putchar() to output a character.





void printDate(char date[])


{





int n;


for (n = 4; n %26lt; 6; n++)


{


putchar(date[n]);


}


printf("/");


int m;


for (m = 6; m %26lt; 8; m++)


{


putchar(date[m]);


}


printf("/");


int i;


for (i = 0; i %26lt; 4; i++)


{


putchar(date[i]);


}


printf(" at ");


int z;


for (z = 8; z %26lt; 12; z++)


{


putchar(date[z]);


}


}