473,473 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

full in the blank , making use of a[10] to outputcontent of i

#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);
}

can anyone help me?

Feb 15 '07 #1
16 1348
"liking C lang.Chinese" wrote:
>
#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);
}

can anyone help me?
We don't do homework. Hint, read the C standard for library
functions. However ...

Your instructor has given you an impossible task, because the
outline program is invalid in the first place. main returns an
int, and should be written as "int main(void)" anyhow (must be for
C99). The program fails to return a value, which is invalid for
C90. So regardless of what standard you use, the program is
invalid.

Find an instructor or course that at least knows the subject they
are trying to teach.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews

Feb 15 '07 #2
On 2ÔÂ15ÈÕ, ÏÂÎç2ʱ57·Ö, CBFalconer <cbfalco...@yahoo.comwrote:
"liking C lang.Chinese" wrote:
#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);
}
can anyone help me?

We don't do homework. Hint, read the C standard for library
functions. However ...

Your instructor has given you an impossible task, because the
outline program is invalid in the first place. main returns an
int, and should be written as "int main(void)" anyhow (must be for
C99). The program fails to return a value, which is invalid for
C90. So regardless of what standard you use, the program is
invalid.

Find an instructor or course that at least knows the subject they
are trying to teach.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
Thank you very very very much.

Feb 15 '07 #3
On 2ÔÂ15ÈÕ, ÏÂÎç2ʱ57·Ö, CBFalconer <cbfalco...@yahoo.comwrote:
"liking C lang.Chinese" wrote:
#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);
}
can anyone help me?

We don't do homework. Hint, read the C standard for library
functions. However ...

Your instructor has given you an impossible task, because the
outline program is invalid in the first place. main returns an
int, and should be written as "int main(void)" anyhow (must be for
C99). The program fails to return a value, which is invalid for
C90. So regardless of what standard you use, the program is
invalid.

Find an instructor or course that at least knows the subject they
are trying to teach.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
but I use the toolis truboc2.0 .

Feb 15 '07 #4
CBFalconer wrote:
"liking C lang.Chinese" wrote:

#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);
}

can anyone help me?

We don't do homework. Hint, read the C standard for library
functions. However ...

Your instructor has given you an impossible task, because the
outline program is invalid in the first place. main returns an
int,
And main() is declared as returning int.
and should be written as "int main(void)" anyhow (must be for
C99).
Must be for C99, but for C90, it's more style than anything.
The program fails to return a value, which is invalid for
C90.
No, it's valid. You can't assume it will return a successful status,
but it will return properly.
So regardless of what standard you use, the program is
invalid.

Find an instructor or course that at least knows the subject they
are trying to teach.
Feb 15 '07 #5
On 2ÔÂ15ÈÕ, ÏÂÎç4ʱ10·Ö, "liking C lang." <2008mu....@gmail.comwrote:
On 2ÔÂ15ÈÕ, ÏÂÎç2ʱ57·Ö, CBFalconer <cbfalco...@yahoo.comwrote:


"liking C lang.Chinese" wrote:
#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);
}
can anyone help me?
We don't do homework. Hint, read the C standard for library
functions. However ...
Your instructor has given you an impossible task, because the
outline program is invalid in the first place. main returns an
int, and should be written as "int main(void)" anyhow (must be for
C99). The program fails to return a value, which is invalid for
C90. So regardless of what standard you use, the program is
invalid.
Find an instructor or course that at least knows the subject they
are trying to teach.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews

but I use the toolis truboc2.0 .- Òþ²Ø±»ÒýÓÃÎÄ×Ö -

- ÏÔʾÒýÓõÄÎÄ×Ö -
but i use the tool is turboc2.0

Feb 15 '07 #6
liking C lang.Chinese wrote:
>
#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);
}

can anyone help me?
/* BEGIN new.c */

#include<stdio.h>

int main(void)
{
int i;
size_t count;
unsigned char a[sizeof i + 1] = {0};

puts("Enter an integer.");
if (scanf("%d", &i) == 1) {
for (count = 0; count != sizeof i; ++count) {
a[count] = ((unsigned char *)&i)[count];
}
printf("%s\n", a);
printf("The byte representation of %d is:\n", i);
for (count = 0; count != sizeof i; ++count) {
printf("%u\n", (unsigned)a[count]);
}
}
return 0;
}

/* END new.c */

--
pete
Feb 15 '07 #7
CBFalconer <cb********@yahoo.comwrites:
"liking C lang.Chinese" wrote:
>>
#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);
}

can anyone help me?

We don't do homework. Hint, read the C standard for library
functions. However ...

Your instructor has given you an impossible task, because the
outline program is invalid in the first place. main returns an
int, and should be written as "int main(void)" anyhow (must be for
C99). The program fails to return a value, which is invalid for
C90. So regardless of what standard you use, the program is
invalid.

Find an instructor or course that at least knows the subject they
are trying to teach.
Yes. That will help him pass his course. Congratulations on surpassing
yourself in your desire to show off. And the missing "int" in the
declatation does not, in any way, invalidate the rest of the code for
the sake of this students course.
Feb 15 '07 #8
Harald van D?k <tr*****@gmail.comwrote:
CBFalconer wrote:
The program fails to return a value, which is invalid for
C90.
No, it's valid. You can't assume it will return a successful status,
but it will return properly.
This exact point has come up several times in many threads on the
group in the past week or so. Perhaps a consensus should be reached
(with help from comp.std.c) and a new FAQ should be created. It
certainly seems to be a recurring cause of rehashed discussion.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Feb 15 '07 #9
On 2ÔÂ15ÈÕ, ÏÂÎç8ʱ14·Ö, pete <pfil...@mindspring.comwrote:
liking C lang.Chinese wrote:
#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);
}
can anyone help me?

/* BEGIN new.c */

#include<stdio.h>

int main(void)
{
int i;
size_t count;
unsigned char a[sizeof i + 1] = {0};

puts("Enter an integer.");
if (scanf("%d", &i) == 1) {
for (count = 0; count != sizeof i; ++count) {
a[count] = ((unsigned char *)&i)[count];
}
printf("%s\n", a);
printf("The byte representation of %d is:\n", i);
for (count = 0; count != sizeof i; ++count) {
printf("%u\n", (unsigned)a[count]);
}
}
return 0;

}

/* END new.c */

--
pete
thank you very much!

Feb 15 '07 #10
"liking C lang.Chinese" wrote:
>
#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);
}

can anyone help me?
Aside from the nitpicking of other parts of this thread, it has yet
to be pointed out that "a[10]" does not exist. You have declared a
as an array of 10 chars, with subscripts running from 0 through 9.
Any attempt to access "a[10]" invokes undefined behavior.

Now, it's possible that your instructor is assuming that the compiler
that you are using will happen to place i at the address that would
have been taken by a[10], if a[10] had existed, and therefore you can
use the assumption that "(int *)(&a[10])" is the same as "&i".

Note, however, that this is a very dangerous assumption to make, and
such code will reformat the hard drive on the DS-6000.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Feb 15 '07 #11
On 15 Feb, 05:51, "liking C lang.Chinese" <2008mu...@gmail.comwrote:
#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);

}

can anyone help me?
the code as posted is riddled with bugs and it is not
completly clear what your instructor (YI) wants.

The code uses scanf() to read an int, it does something YI
wants you to fill in, then it uses printf() to print a
string (an array of char) (he forgot to put \n at the end).

So the "someting" that needs to be done is to convert an int
into an array of char. Now have you come across a function
to do this on your course? Or does your textbook mention it?
--
Nick Keighley

Feb 15 '07 #12
On 2ÔÂ16ÈÕ, ÉÏÎç12ʱ45·Ö, "Nick Keighley" <nick_keighley_nos...@hotmail.com>
wrote:
On 15 Feb, 05:51, "liking C lang.Chinese" <2008mu...@gmail.comwrote:
#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);
}
can anyone help me?

the code as posted is riddled with bugs and it is not
completly clear what your instructor (YI) wants.

The code uses scanf() to read an int, it does something YI
wants you to fill in, then it uses printf() to print a
string (an array of char) (he forgot to put \n at the end).

So the "someting" that needs to be done is to convert an int
into an array of char. Now have you come across a function
to do this on your course? Or does your textbook mention it?

Nick Keighley
How can I convert an int into an array of char?

Feb 15 '07 #13
liking C lang. said:
On 2?16?, ??12?45?, "Nick Keighley" <nick_keighley_nos...@hotmail.com>
wrote:
<snip>
>So the "someting" that needs to be done is to convert an int
into an array of char. Now have you come across a function
to do this on your course? Or does your textbook mention it?
How can I convert an int into an array of char?
See K&R2 p155.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Feb 15 '07 #14
Kenneth Brody <ke******@spamcop.netwrites:
"liking C lang.Chinese" wrote:
>>
#include<stdio.h>
main()
{
int i;
char a[10];
scanf("%d",&i);
_________________
_________________\\*full in the blank , making use of a[10] to
outputcontent of i*\\
printf("%s",a);
}

can anyone help me?

Aside from the nitpicking of other parts of this thread, it has yet
to be pointed out that "a[10]" does not exist. You have declared a
as an array of 10 chars, with subscripts running from 0 through 9.
Any attempt to access "a[10]" invokes undefined behavior.
[...]

I suspect that the "a[10]" in the comment doesn't refer to element 10
of the array, but to the object a which is an array of 10 elements. I
think it's intended to be an informal notation, similar to the common
use of "foo()" to refer to a function named "foo" rather than to the
result returned by the function "foo".

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 15 '07 #15
On 15 Feb, 18:09, Richard Heathfield <r...@see.sig.invalidwrote:
liking C lang. said:
On 2?16?, ??12?45?, "Nick Keighley" <nick_keighley_nos...@hotmail.com>
wrote:
So the "someting" that needs to be done is to convert an int
into an array of char. Now have you come across a function
to do this on your course? Or does your textbook mention it?
How can I convert an int into an array of char?

See K&R2 p155.
this is hard work sometimes. Some days you wonder if it would
just be easier to give 'em the answer.
--
Nick Keighley

Feb 16 '07 #16
Nick Keighley said:
On 15 Feb, 18:09, Richard Heathfield <r...@see.sig.invalidwrote:
>liking C lang. said:
On 2?16?, ??12?45?, "Nick Keighley"
<nick_keighley_nos...@hotmail.comwrote:
>So the "someting" that needs to be done is to convert an int
into an array of char. Now have you come across a function
to do this on your course? Or does your textbook mention it?
How can I convert an int into an array of char?

See K&R2 p155.

this is hard work sometimes. Some days you wonder if it would
just be easier to give 'em the answer.
Yes, spoonfeeding him would have been a lot quicker than finding K&R2
(which had somehow levitated itself off my desk and buried itself
between "Common Controls and Messages" and UNPv1), and then digging out
the appropriate page reference.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Feb 16 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Pastrovick | last post by:
When writing an HTML table after a PHP database query very occasionally (1 out of ten times -- same code) the HTML page is truncated and cells/or full final rows of table are missing. Looking at...
14
by: charlie_M | last post by:
Is there a way to blank the screen in a FORM's onsubmit=... to blank the screen for the user?? I asked this before and got a way to blank a table by id with ...
6
by: MX1 | last post by:
Please help if you can. I have a form with an address field. There are 6 fields: Name1 Name2 Address1 Address2 CityStateZip Country
14
by: vicky | last post by:
SUMMARY: THREE YEARS of and continuing MENTAL TORTURE, TERRORISM, SADISM and BLATANT human rights violations by FBI SADISTS and PERVERTS. Please SAVE this post on your hard disks or email...
6
by: John Dalberg | last post by:
Why does IE not show the full html source when I try to view the source?? I mean why does it hide a few features. Previously I had an issue where the data grid html representation was hidden in...
2
by: JohnR | last post by:
When creating an msAccess db within the Access UI itself the fields that are text are NOT padded with blanks. For example, if I have a 10 char field and put in "HI" and then when I come back to...
2
by: Olveres | last post by:
Hi, I have managed to work out how to add new lines into a calculated text box. However in this text box some of the outcome fields are empty however when previewing the report it includes the...
4
by: moiashvin | last post by:
I am writing a Windows Mobile CE 5.0 c# application, and I want my form to be completely full screen, and not movable. I have been able to make the form unmovable and maximized. However, want it to...
6
by: Jeff | last post by:
Nearly identical post in alt.www.webmaster, where it is languishing. I'd like a column that flows the full height of a page, even if you scroll down. If I did this: <div style="width:...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.