Thread: Literal String Confusion

  1. #1
    Registered User
    Join Date
    Dec 2017
    Posts
    1

    Exclamation Literal String Confusion

    Hello,

    I'm a complete novice, it's a wonderland of adventure. I hope someone can answer my question on this perplexing scenario. To amuse myself and lighten my learning, I was typing humourous lines as literal strings within my printf brackets. When moving from an 'if statements' example, on to an 'else if' example, I deleted some of the prior code lines and 'saved as', to simplify and understand better was going on. What I found odd, was although the code runs fine, I keep getting a print out of a literal string I deleted. At least I thought I had, it is no longer visible within the code, but it prints out the deleted line when run. Baffled is a pretty inadequate word to use right now. Can anyone explain how this can be? Thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Without seeing the code, we can't possibly say.

    99% of such cases are the result of not compiling the code properly.
    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.

  3. #3
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    If the string literal does not appear in your source code but it is printed out when you run the executable, then you are running an old executable, not one being generated from the current source file. Try deleting the executable first.
    A little inaccuracy saves tons of explanation. - H.H. Munro

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Modifying a string literal.
    By Eman in forum C++ Programming
    Replies: 45
    Last Post: 12-30-2010, 06:37 PM
  2. question about string literal
    By pangzhang in forum C Programming
    Replies: 6
    Last Post: 07-31-2010, 07:25 AM
  3. string literal assignment
    By @nthony in forum C Programming
    Replies: 1
    Last Post: 03-13-2009, 12:06 PM
  4. Replies: 7
    Last Post: 07-18-2005, 08:43 AM
  5. String literal
    By subdene in forum C++ Programming
    Replies: 5
    Last Post: 11-05-2002, 02:10 PM

Tags for this Thread