confused..again

Discussion in 'C Programming' started by Bill Cunningham, Dec 30, 2007.

  1. 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
     
    Bill Cunningham, Dec 30, 2007
    #1
    1. Advertising

  2. Bill Cunningham

    Eric Sosman Guest

    Bill Cunningham wrote:
    > 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);

    --
    Eric Sosman
    lid
     
    Eric Sosman, Dec 30, 2007
    #2
    1. Advertising

  3. In article <s9Tdj.35028$NL5.2831@trnddc05>,
    Bill Cunningham <> wrote:
    > 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.


    printf("is? %s", name);
    --
    "No one has the right to destroy another person's belief by
    demanding empirical evidence." -- Ann Landers
     
    Walter Roberson, Dec 30, 2007
    #3
  4. Bill Cunningham

    Serve Lau Guest

    "Bill Cunningham" <> schreef in bericht
    news:s9Tdj.35028$NL5.2831@trnddc05...
    > 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?
     
    Serve Lau, Dec 30, 2007
    #4
  5. Bill Cunningham

    Default User Guest

    Bill Cunningham wrote:

    > 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
     
    Default User, Dec 30, 2007
    #5
  6. "Eric Sosman" <> wrote in message
    news:eek:...
    > Bill Cunningham wrote:
    >> 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
     
    Bill Cunningham, Dec 30, 2007
    #6
  7. > 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
     
    Bill Cunningham, Dec 30, 2007
    #7
  8. > 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
     
    Bill Cunningham, Dec 30, 2007
    #8
  9. On Sun, 30 Dec 2007 23:14:03 +0000, Bill Cunningham wrote:

    > 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.
     
    Mark McIntyre, Dec 31, 2007
    #9
  10. On Sun, 30 Dec 2007 21:37:04 +0000, Default User wrote:

    > 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.
     
    Mark McIntyre, Dec 31, 2007
    #10
  11. "Mark McIntyre" <> wrote in message
    news:rYWdj.22891$...
    > On Sun, 30 Dec 2007 23:14:03 +0000, Bill Cunningham wrote:
    >
    >> 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.


    Thanks Mark.

    Bill
     
    Bill Cunningham, Dec 31, 2007
    #11
  12. "Mark McIntyre" <> wrote in message
    news:SZWdj.22892$...
    > On Sun, 30 Dec 2007 21:37:04 +0000, Default User wrote:
    >
    >> 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.


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

    Bill
     
    Bill Cunningham, Dec 31, 2007
    #12
  13. Bill Cunningham

    Randy Howard Guest

    On Sun, 30 Dec 2007 18:46:42 -0600, Mark McIntyre wrote
    (in article <SZWdj.22892$>):

    > On Sun, 30 Dec 2007 21:37:04 +0000, Default User wrote:
    >
    >> 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.


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


    --
    Randy Howard (2reply remove FOOBAR)
    "The power of accurate observation is called cynicism by those
    who have not got it." - George Bernard Shaw
     
    Randy Howard, Dec 31, 2007
    #13
  14. Bill Cunningham

    Serve Lau Guest

    "Bill Cunningham" <> schreef in bericht
    news:noXdj.4136$ZI4.2742@trnddc08...
    >
    > "Mark McIntyre" <> wrote in message
    > news:SZWdj.22892$...
    >> On Sun, 30 Dec 2007 21:37:04 +0000, Default User wrote:
    >>
    >>> 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.

    >
    > 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
     
    Serve Lau, Dec 31, 2007
    #14
  15. Bill Cunningham

    Default User Guest

    Bill Cunningham wrote:

    > > 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()?


    > 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
     
    Default User, Dec 31, 2007
    #15
  16. Bill Cunningham

    Default User Guest

    Mark McIntyre wrote:

    > On Sun, 30 Dec 2007 21:37:04 +0000, Default User wrote:
    >
    > > 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.
     
    Default User, Dec 31, 2007
    #16
  17. Bill Cunningham

    Default User Guest

    Mark McIntyre wrote:

    > On Sun, 30 Dec 2007 21:37:04 +0000, Default User wrote:
    >
    > > 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.



    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
     
    Default User, Dec 31, 2007
    #17
  18. On Mon, 31 Dec 2007 17:04:02 +0100, Serve Lau wrote:

    >> 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?


    "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.... :)
     
    Mark McIntyre, Dec 31, 2007
    #18
  19. On Mon, 31 Dec 2007 18:42:29 +0000, Default User wrote:

    > 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?
     
    Mark McIntyre, Dec 31, 2007
    #19
  20. Bill Cunningham

    Randy Howard Guest

    On Mon, 31 Dec 2007 17:16:25 -0600, Mark McIntyre wrote
    (in article <dLeej.25267$>):

    > On Mon, 31 Dec 2007 18:42:29 +0000, Default User wrote:
    >
    >> 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?
    >


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

    --
    Randy Howard (2reply remove FOOBAR)
    "The power of accurate observation is called cynicism by those
    who have not got it." - George Bernard Shaw
     
    Randy Howard, Dec 31, 2007
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. amit
    Replies:
    0
    Views:
    413
  2. che
    Replies:
    2
    Views:
    524
  3. It's me

    Newbie getting confused again

    It's me, Mar 5, 2005, in forum: Python
    Replies:
    6
    Views:
    337
    It's me
    Mar 5, 2005
  4. abcd

    Importing again and again

    abcd, Jun 8, 2006, in forum: Python
    Replies:
    9
    Views:
    342
    Maric Michaud
    Jun 9, 2006
  5. mcl
    Replies:
    10
    Views:
    472
Loading...

Share This Page