Thread: prompted string problems

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    6

    prompted string problems

    I am writing a program that prompts the user for a string. This string will then have an extracted substing. I've written this code below but whenever I compile it It'll prompt the user for the string and then freeze up. I know my problem is with the way I am storing the initial string but can't find in my book how to do this. I'm new and yes this if for homework. I couldn't find help with this on any other postings. I just want to be pointed in the right way. Any help is appreciated. Thanks,prompted string problems-10-4-jpg

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    If there's any whitespace in your inputted text it will foul things up. You'll have to use something like fgets() to get the string instead of scanf().
    If you understand what you're doing, you're not learning anything.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Also, copy / paste your code, NOT a screen-shot.
    We can't copy your code without a lot of pointless effort to read your picture and manually type the code (that won't happen).

    It should look like this
    Code:
    int main ( ) {
        // code here
        return 0;
    }
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 09-05-2010, 04:43 AM
  2. string problems
    By purejoker in forum C Programming
    Replies: 3
    Last Post: 03-10-2009, 02:15 PM
  3. String Problems
    By Junior89 in forum C++ Programming
    Replies: 8
    Last Post: 12-21-2004, 07:00 PM
  4. String problems
    By sirSolarius in forum C++ Programming
    Replies: 5
    Last Post: 12-18-2003, 08:07 PM
  5. Still string problems
    By LavaLamp27 in forum C++ Programming
    Replies: 2
    Last Post: 10-05-2001, 11:01 PM

Tags for this Thread