#include %26lt;stdio.h%26gt;
int
main()
{
int i = 12;
char tmp[32];
snprintf(tmp, sizeof tmp, "%d", i);
puts(tmp);
return 0;
}
OR
#include %26lt;stdio.h%26gt;
%26gt;
%26gt; void putint(int x);
%26gt;
%26gt; int main(void)
%26gt; {
%26gt; puts("[output]");
%26gt; putint(13725);
%26gt; putchar('\n');
%26gt; putint(5500);
%26gt; putchar('\n');
%26gt; return 0;
%26gt; }
%26gt;
%26gt; void putint(int x)
%26gt; {
%26gt; if (x) {
%26gt; putint(x / 10);
%26gt; putchar('0' + x % 10);
%26gt; }
%26gt; }
%26gt;
%26gt; [output]
%26gt; 13725
%26gt; 5500
OR
#include %26lt;stdio.h%26gt;
#include %26lt;limits.h%26gt;
...
char buff[1+(CHAR_BIT*sizeof(int)+2)/3+1];
sprintf (buff, "%d", the_integer);
puts (buff);
How to print a string without using print statement in c?
fputs(const char* string, FILE* stream).
since stdout is a file just do:
fputs("string to print",stdout);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment