prompted string problems

This is a discussion on prompted string problems within the C Programming forums, part of the General Programming Boards category; I am writing a program that prompts the user for a string. This string will then have an extracted substing. ...

  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,Name:  10.4.jpg
Views: 102
Size:  138.5 KB

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,171
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,762
    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.
    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. Replies: 4
    Last Post: 09-05-2010, 05:43 AM
  2. string problems
    By purejoker in forum C Programming
    Replies: 3
    Last Post: 03-10-2009, 03: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-06-2001, 12:01 AM

Tags for this Thread


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