newbie...please help

C

cj

Hello! I need some major help! I took this computer programming class
to learn more about computers. Picked this class because it had a
section to learn web page design but now I have to complete the section

about the c language and I have no clue! I'm totally stressing out
because it is blowing my mind and if I don't complete all the lessons I

don't receive a certificate of completion. Please someone help me! Here

are a few questions:


What is the length returned by the "strlen()" function?
char dog[80]


strcpy (dog,"I am a dog");
strlen (dog);


Which animal will be replaced with "fly" in the following code
fragment?
char animals [ ] [3][6] = {
"cow","pig","dog","rat","bat","hen","eel","ant","cat","ox","owl","yak","ram­","bee","doe"}

strcpy(animals [2] [1] , "fly");


What is the difference between the 7's in thse two statements?
long cat [7];
cat[7] = 5L


I will only ask 3 for now until I see the response I get from anyone
willing to help. I appreciate any help! Thanks
 
E

Eric Sosman

cj said:
Hello! I need some major help! [...]

You do, indeed. Try selling pencils on street
corners; if you can cut off a leg and exhibit a
festering stump you'll get more pity. Good luck!
 
M

Mike Wahler

cj said:
Hello! I need some major help! I took this computer programming class
to learn more about computers. Picked this class because it had a
section to learn web page design but now I have to complete the section

about the c language and I have no clue! I'm totally stressing out
because it is blowing my mind and if I don't complete all the lessons I

don't receive a certificate of completion. Please someone help me! Here

are a few questions:


What is the length returned by the "strlen()" function?
char dog[80]


strcpy (dog,"I am a dog");
strlen (dog);


Which animal will be replaced with "fly" in the following code
fragment?
char animals [ ] [3][6] = {
"cow","pig","dog","rat","bat","hen","eel","ant","cat","ox","owl","yak","ram­","bee","doe"}

strcpy(animals [2] [1] , "fly");


What is the difference between the 7's in thse two statements?
long cat [7];
cat[7] = 5L
I will only ask 3 for now until I see the response I get from anyone
willing to help. I appreciate any help! Thanks


The answers can be found in your textbook.

Yes, we can and will *help*, but we won't do it for you.
Show that you've made an effort. Review your text,
post your attempts at answers, and we'll help you
make sure they're correct and that you know *why*
they're correct.

-Mike
 
M

manthrainc

Hi,
Why you have to worry when there is c compiler.Compile the code and try
debugging it or try printing the output.Try learening installing the
compiler and do the code and outputting.And if that seemed out of your
head there are people out here who could hel[p on that.These questions
are simple....You must understand that.

OK
strlen()
returns the number of characters in the argument passed to it.
eg
strlen("subin")
it returns 5

now you think.

Mike said:
cj said:
Hello! I need some major help! I took this computer programming class
to learn more about computers. Picked this class because it had a
section to learn web page design but now I have to complete the section

about the c language and I have no clue! I'm totally stressing out
because it is blowing my mind and if I don't complete all the lessons I

don't receive a certificate of completion. Please someone help me! Here

are a few questions:


What is the length returned by the "strlen()" function?
char dog[80]


strcpy (dog,"I am a dog");
strlen (dog);


Which animal will be replaced with "fly" in the following code
fragment?
char animals [ ] [3][6] = {
"cow","pig","dog","rat","bat","hen","eel","ant","cat","ox","owl","yak","ram­","bee","doe"}

strcpy(animals [2] [1] , "fly");


What is the difference between the 7's in thse two statements?
long cat [7];
cat[7] = 5L
I will only ask 3 for now until I see the response I get from anyone
willing to help. I appreciate any help! Thanks


The answers can be found in your textbook.

Yes, we can and will *help*, but we won't do it for you.
Show that you've made an effort. Review your text,
post your attempts at answers, and we'll help you
make sure they're correct and that you know *why*
they're correct.

-Mike
 
B

Bart

cj said:
Which animal will be replaced with "fly" in the following code
fragment?
char animals [ ] [3][6] = {
"cow","pig","dog","rat","bat","hen","eel","ant","cat","ox","owl","yak","ram­","bee","doe"}

strcpy(animals [2] [1] , "fly");

I don't get this either. A 3D array is declared then initialised with
2D content. Am I missing something? It works better without the [3] and
the [1].

Bart
 
C

Christopher Benson-Manica

Why you have to worry when there is c compiler.Compile the code and try
debugging it or try printing the output.Try learening installing the
compiler and do the code and outputting.And if that seemed out of your
head there are people out here who could hel[p on that.These questions
are simple....You must understand that.

1) Bottom post, please. This post is an example of the correct
technique.

2) It sounds like you're responding to OP, but you've quoted Mike's
post.

(snip quoted text)
 
C

Christopher Benson-Manica

cj said:
Hello! I need some major help! I took this computer programming class
to learn more about computers. Picked this class because it had a
section to learn web page design but now I have to complete the section
about the c language and I have no clue!

Should have read the course description more carefully, hm? Either
drop the class or make an effort to actually learn the material. If
you can't handle learning rudimentary programming, you're going to
make a very poor web page designer.

Incidentally, for the price of this course you foolishly registered
for, you could have bought a book on HTML that would have taught you
far more. Then again, learning doesn't seem to be high on your
agenda.
 
A

Andrew Poelstra

Bart said:
cj said:
Which animal will be replaced with "fly" in the following code
fragment?
char animals [ ] [3][6] = {
"cow","pig","dog","rat","bat","hen","eel","ant","cat","ox","owl","yak","ram­","bee","doe"}

strcpy(animals [2] [1] , "fly");

I don't get this either. A 3D array is declared then initialised with
2D content. Am I missing something? It works better without the [3] and
the [1].

Bart

Because a string is in itself an array, a 2D array of strings would
actually be a 3D array.
That's why you shouldn't learn C without programming experience: It's
hellishly complicated.

Ex. animals[0][0][0] == 'c', whereas animals [0][0] = "cow" and animals
[0] = [the address in memory of "cow"]


In the textbook of the original poster, this information should be
under "arrays", "multidimensional arrays", or "strings". The index
should have all three of those.
 
B

Bart

Andrew said:
Bart wrote:
> char animals [ ] [3][6] = {
"cow","pig","dog","rat","bat","hen","eel","ant","cat","ox","owl","yak","ram­","bee","doe"}
I don't get this either. A 3D array is declared then initialised with
2D content. Am I missing something? It works better without the [3] and
the [1].
Because a string is in itself an array, a 2D array of strings would
actually be a 3D array.
That's why you shouldn't learn C without programming experience: It's
hellishly complicated.

Ex. animals[0][0][0] == 'c', whereas animals [0][0] = "cow" and animals
[0] = [the address in memory of "cow"]

I think I get it now, the init data should have looked like:

{{"cow","pig","dog"},{"rat","bat","hen"},{"eel","ant","cat"},{"ox","owl","yak"},{"ram","bee","doe"}};

instead of the linear:

{"cow","pig","dog","rat","bat","hen","eel","ant","cat","ox","owl","yak","ram","bee","doe"};

but the 'magic' of C makes that correct.


Bart
 
C

cj

Thanks to all who replied! Some of the info was very helpful which is
what I was looking for. Thanks again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top