473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

question about printf

1
what is the output of

void main()
{
printf("%d");
}
Apr 11 '07 #1
11 1635
RedSon
5,000 Expert 4TB
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

Please read the Posting Guidelines and particularly the Coursework Posting Guidlines.

Then when you are ready post a new question in this thread.

MODERATOR
Apr 11 '07 #2
RedSon
5,000 Expert 4TB
Using a good, clear thread title is important. The reasons for this are:
  • We want this site to grow, many of our new members find the site using a search engine, by using a good thread title you will help us grow the site by helping us get better search engine rankings.
  • Using a good title will benefit you too because other members of the forum will be less likely to skip over your thread and it allows the experts to quickly scan through the forum for questions they know the answer to.
  • If the threads are well titled it allows other users to easily see if there have been any threads that could be relevant to their own current problem.
  • It is in everybody's best interests to post properly titled threads as the more time the moderators have to spend on managing titles the less time they have available to give answers to the questions posed.
Apr 11 '07 #3
Savage
1,764 Expert 1GB
The output will be ZERO


Savage
Apr 11 '07 #4
nmadct
83 Expert
what is the output of

Expand|Select|Wrap|Line Numbers
  1. void main()
  2. {
  3.     printf("%d");
  4. }
  5.  
Try it and find out!
Apr 11 '07 #5
sicarie
4,677 Expert Mod 4TB
The output will be ZERO


Savage
Umm, I'm pretty sure that's incorrect. Did you try running it?
Apr 11 '07 #6
Savage
1,764 Expert 1GB
Umm, I'm pretty sure that's incorrect. Did you try running it?
Yes,I runed it and it gaved me a 0.

Savage
Apr 11 '07 #7
Banfa
9,065 Expert Mod 8TB
The output could be anything, it invokes undefined behaviour on at least 2 counts.
Apr 11 '07 #8
Ganon11
3,652 Expert 2GB
The output could be anything, it invokes undefined behaviour on at least 2 counts.
Let me guess:

1) void main() instead of int main()
2) printf("%d"); is supposed to print an integer value, but no such value is specified.
Apr 11 '07 #9
chella
51
Hi,
The value of the statement printf("%d") varies depending on the compiler we use.
In Unix, cc compiler will produce a result as some unknown integer value.
In Turbo C compiler the result will be zero.

This depends on the compiler which we use


Regrads,
Chella
Apr 12 '07 #10
JosAH
11,448 Expert 8TB
Hi,
The value of the statement printf("%d") varies depending on the compiler we use.
In Unix, cc compiler will produce a result as some unknown integer value.
In Turbo C compiler the result will be zero.

This depends on the compiler which we use


Regrads,
Chella
My compiler makes daemons fly out of your nose. As said before: calling the
printf function like this causes undefined behaviour. Every (educated?) guess
what the output would/could be is just guessing. Nothing can be said about it.

kind regards,

Jos
Apr 12 '07 #11
Banfa
9,065 Expert Mod 8TB
1) void main() instead of int main()
2) printf("%d"); is supposed to print an integer value, but no such value is specified.
That is what I was thinking of :D
Apr 12 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Wenjie | last post by:
Hello, Is printf("%d", var); OK for the unsigned long var = SOME_VAR? Or should some other print format be specified? Thanks and best regards, Wenjie
17
by: herrcho | last post by:
#include <stdio.h> int main() { int i; char *p="sarang"; for(i=0;i<4;i++) printf("%c",*(p+i)); printf("\n"); for(i=0;i<4;i++)
2
by: yezi | last post by:
Hi, ALl: The following code is to canculate 2 vector distance. Suppose the vectore is stored in some txt file like -1 0.34 0 0.045 1 0.98 1 0.01
3
by: kkk | last post by:
I am practicing LRU by writing a simulating c programme, but encounter a problem. The problem is when a page hit occurred (simulated process request (contains requested page) a page, which has...
9
by: william | last post by:
When implementing Linked list, stack, or trees, we always use pointers to 'link' the nodes. And every node is always defined as: struct node { type data; //data this node contains ... node *...
17
by: manuthomas23 | last post by:
I have a question: What will be the value of j in the following code? and why is it so? int i; for( i = 0; i < 1; i++ ) { switch( i ) { case 0: i += 5;
1
by: erizy | last post by:
There are situations that exception could be throw within constructor and we usually employ auto_ptr to protect resources. But if we do not have auto_ptr can we use the following technique to handle...
3
by: golden | last post by:
Hello, I am going to ask a question regarding write and lseek. I will provide code at the end of this, but first some background. I am trying to identify the cause of some latency in...
160
by: raphfrk | last post by:
Is this valid? int a; void *b; b = (void *)a; // b points to a b += 5*sizeof(*a); // b points to a a = 100;
2
by: Giorgos Keramidas | last post by:
On Sun, 05 Oct 2008 18:22:13 +0300, Giorgos Keramidas <keramida@ceid.upatras.grwrote: My apologies. I should have been less hasty to hit `post'. If showtext() is passed a null pointer, it may...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.