confused..again

B

Bill Cunningham

It is very easy to see what I am trying to do with this code:

#include <stdio.h>

main(){
char name[200];
printf ("Enter -> ");
fflush (stdout);
fgets (name,200,stdin);
printf("is? ",name);}

I have also tried this with the last line with printf

printf("is? %c",name);

Either way same results. Printf will not print the value of name.

Bill
 
E

Eric Sosman

Bill said:
It is very easy to see what I am trying to do with this code:

I'm not finding it easy. Please don't assume everyone
else is as perceptive as you are.
#include <stdio.h>

main(){
char name[200];
printf ("Enter -> ");
fflush (stdout);
fgets (name,200,stdin);
printf("is? ",name);}

I have also tried this with the last line with printf

printf("is? %c",name);

Either way same results. Printf will not print the value of name.

Perhaps you want

printf ("is ? %s", name);
 
W

Walter Roberson

S

Serve Lau

Bill Cunningham said:
It is very easy to see what I am trying to do with this code:

#include <stdio.h>

main(){
char name[200];
printf ("Enter -> ");
fflush (stdout);
fgets (name,200,stdin);
printf("is? ",name);}

I have also tried this with the last line with printf

printf("is? %c",name);

Either way same results. Printf will not print the value of name.

Strange, I remember somebody years ago with the same name asking these same
kind of newbie questions.

Here, from 2003
http://groups.google.com/group/comp...uthor:bill+author:cunningham#1934df188f17ad68

complete list:
http://groups.google.com/groups?q=g...miny=1981&as_maxd=30&as_maxm=12&as_maxy=2007&

a troll whose humour I dont understand or what is this?
 
D

Default User

Bill said:
It is very easy to see what I am trying to do with this code:

#include <stdio.h>

main(){
char name[200];
printf ("Enter -> ");
fflush (stdout);
fgets (name,200,stdin);
printf("is? ",name);}

I have also tried this with the last line with printf

printf("is? %c",name);

Either way same results. Printf will not print the value of name.

You've supposedly been learning C for months if not years. What book
are you using that doesn't give the procedure for printing strings with
printf()?





Brian
 
B

Bill Cunningham

Eric Sosman said:
Bill said:
It is very easy to see what I am trying to do with this code:

I'm not finding it easy. Please don't assume everyone
else is as perceptive as you are.
#include <stdio.h>

main(){
char name[200];
printf ("Enter -> ");
fflush (stdout);
fgets (name,200,stdin);
printf("is? ",name);}

I have also tried this with the last line with printf

printf("is? %c",name);

Either way same results. Printf will not print the value of name.

Perhaps you want

printf ("is ? %s", name);
Yes minor stumbling block.
#include <stdio.h>

main(){
char name[200];
char name2[200];
printf ("Enter -> ");
fflush (stdout);
fgets (name,200,stdin);
printf("is? %s",name);
printf("what you mean? Try again.");
fflush(stdout);
fgets(name2,200,stdin);
if (name==name2) {printf("ok");}
else if (name!=name2){
printf("Sorry try again.");
return main();}
return 0;}

THanks now there seems to be an error with if here somewhere. I will try to
figure it out if not I would appreciate a look over.

Bill
 
B

Bill Cunningham

You've supposedly been learning C for months if not years. What book
are you using that doesn't give the procedure for printing strings with
printf()?





Brian

I have been away from C for over a year. Now I'm trying to give it a go
again and studying again.

Bill
 
B

Bill Cunningham

THanks now there seems to be an error with if here somewhere. I will try
to figure it out if not I would appreciate a look over.

Bill

OK I got it. Don't use else here.

Bill
 
M

Mark McIntyre

if (name==name2) {printf("ok");}

You can't compare strings with ==
The code above compares the addresses of name and name2, to see if
they're equal (which, obviously, they aren't).

You must use strcmp or one of its fellows.
 
M

Mark McIntyre

You've supposedly been learning C for months if not years.

My recollection is that the OP stated he has learning difficulties.
Provided he doesn't start trolling, I suggest slack is cut.
 
B

Bill Cunningham

Mark McIntyre said:
You can't compare strings with ==
The code above compares the addresses of name and name2, to see if
they're equal (which, obviously, they aren't).

You must use strcmp or one of its fellows.

Thanks Mark.

Bill
 
B

Bill Cunningham

Mark McIntyre said:
My recollection is that the OP stated he has learning difficulties.
Provided he doesn't start trolling, I suggest slack is cut.

Yes and the medications I'm on don't help that problem.

Bill
 
R

Randy Howard

My recollection is that the OP stated he has learning difficulties.
Provided he doesn't start trolling, I suggest slack is cut.

He could read the google archives for the old answers to his old
questions.
 
S

Serve Lau

Bill Cunningham said:
Yes and the medications I'm on don't help that problem.

No offense meant, but wouldnt it be better to have another hobby where
medication etc does not get in your way? Surely there are more satisfying
things in life than learning something for years without success
 
D

Default User

I have been away from C for over a year. Now I'm trying to give it
a go again and studying again.

That didn't answer the question. What book are you using that doesn't
show the printf() modifiers for strings?




Brian
 
D

Default User

Mark said:
My recollection is that the OP stated he has learning difficulties.
Provided he doesn't start trolling, I suggest slack is cut.


Regardless of difficulties, if he has a reference book and can't follow
simple directions like using the correct printf() modifiers, then he's
wasting his time and ours.

If he's not using a book, then he's REALLY wasting time. Hence my
question.



Brian
 
M

Mark McIntyre

No offense meant, but wouldnt it be better to have another hobby where
medication etc does not get in your way?

"Herr Beethoven, with your condition I suggest you give up music".

In other words, if people didn't struggle against difficult problems,
there would be little progress...
Surely there are more
satisfying things in life than learning something for years without
success

Ask the England cricket team.... :)
 
M

Mark McIntyre

Regardless of difficulties, if he has a reference book and can't follow
simple directions like using the correct printf() modifiers, then he's
wasting his time and ours.

Its pretty obvious that few of us work in special needs teaching, isn't
it?
 
R

Randy Howard

Its pretty obvious that few of us work in special needs teaching, isn't
it?

It's at least clear that some haven't felt compelled to allow political
correctness concerns to alter reality yet.
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top