retrieving strings with spaces from txt files

Discussion in 'C' started by troberts24r, Jul 6, 2008.

  1. troberts24r

    troberts24r New Member

    Joined:
    Jul 6, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    I am using a txt file to store string values that contain spaces.

    The code below is what I am using now:

    if (!(spEncodeDecode = fopen("C:\\encodedecode.txt", "r")))
    {
    printf("\aCould not open input file.\n");
    exit (100);
    } // end if
    int x = 0;
    while (fscanf(spEncodeDecode, "%s", messageCode) != EOF)

    {
    A3 = messageCode;

    }

    the below string is the only string in encodedecode.txt

    ?Q.W,EMRNTBXYUV!ICO PZA;SDLFKGJH


    After I read in a single string, the string that is in A3 is PZA;SDLFKGJH.

    So I am a bit confused.

    I am a student in C.

    Thanks,

    Tom
     
  2. troberts24r

    troberts24r New Member

    Joined:
    Jul 6, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    So no one has a good answer on this question..

    I know I could not have stumped everyone...

    :mean:
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,376
    Likes Received:
    388
    Trophy Points:
    83
    Why don't you read the complete string and then split it.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice