why the compiler skips this line..

This is a discussion on why the compiler skips this line.. within the C Programming forums, part of the General Programming Boards category; it just skips over this Code: scanf("%c",&var); instead of letting me input a char in var ??...

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    why the compiler skips this line..

    it just skips over this
    Code:
    scanf("%c",&var);
    instead of letting me input a char in var
    ??

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Look in some of the half-dozen other of your threads which deal specifically with scanf issues.

    And no, it's YOUR code which is the issue, not your compiler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    there is no mistake
    if it was written in a wrong way
    the program wouldnt have ran from the beggining

    why its skipping this line
    ??

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,407
    Quote Originally Posted by transgalactic2
    there is no mistake
    if it was written in a wrong way
    the program wouldnt have ran from the beggining
    You code can be wrong without causing a compile error.

    Quote Originally Posted by transgalactic2
    why its skipping this line
    ??
    Because you wrote the code such that the flow of control skips that statement with the given input to your program, or maybe the flow of control does not skip that statement, but you have deceived yourself into believing that it does.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    so the scanf is correct?

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,407
    Quote Originally Posted by transgalactic2
    so the scanf is correct?
    Maybe. Without knowing the problem, the context and what exactly is var, concluding the correctness (or lack thereof) of that call of scanf is foolish.

    For example, is this correct?
    Code:
    foo();
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    maybe its skipping because of the \0 in the buffer

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,407
    Okay, enough of games. Post the smallest and simplest compilable program that demonstrates the problem.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,047
    Quote Originally Posted by transgalactic2 View Post
    maybe its skipping because of the \0 in the buffer
    It probably lies in the code that goes before scanf() so it's best to post the code snippet.

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    > there is no mistake
    ROFLMAO - so says you with 1500 posts and no idea STILL how to use scanf properly.

    Originally posted by brewbuck
    Sit back and break out the marsh mallows.

    You continue to use broken ideas, then post 1-liners with NO context, then complain that it doesn't work, and then complain at people trying to help you (futile: adj - helping transgalactic2)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiler Error Help
    By DarkDot in forum C++ Programming
    Replies: 2
    Last Post: 04-03-2007, 11:40 PM
  2. print line by line from a file
    By SoFarAway in forum C Programming
    Replies: 3
    Last Post: 02-18-2005, 12:36 PM
  3. Read only one line using seekg
    By RedZippo in forum C++ Programming
    Replies: 3
    Last Post: 03-31-2004, 10:10 PM
  4. if is faster than switch?
    By skorman00 in forum C++ Programming
    Replies: 32
    Last Post: 03-06-2004, 12:15 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21