Pure C and the '\' character in strings

C and PASCAL (or any other high-level languages) in here please

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
TheNameOfTheGame
Atari God
Atari God
Posts: 1023
Joined: Mon Jul 23, 2012 8:57 pm
Location: Almost Heaven, West Virginia

Pure C and the '\' character in strings

Postby TheNameOfTheGame » Tue Mar 15, 2016 8:29 am

nvm...I see you have to escape the \ with another \ for a literal in a string.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Pure C and the '\' character in strings

Postby simonsunnyboy » Tue Mar 15, 2016 4:49 pm

This is normal C standard behaviour and not specific to Pure C.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
TheNameOfTheGame
Atari God
Atari God
Posts: 1023
Joined: Mon Jul 23, 2012 8:57 pm
Location: Almost Heaven, West Virginia

Re: Pure C and the '\' character in strings

Postby TheNameOfTheGame » Tue Mar 15, 2016 5:24 pm

Thanks. Well, I do already know this really, but since we can't delete messages, I edited my original to what it is now.

Originally I was confused because I saw this in the LIB.HYP file for calling the file selector (the English converted HLP->HYP files from the other thread)

Code: Select all

path[0] = 'A' + Dgetdrv();
path[1] = ':';
Dgetpath( path+2, 0 );
strcat( path, "\\\\*.*");


That \\\\ in the concatenate threw me for a loop. :D

What I finally realized was that the Bash script I made to process the STG files generated from the HLP files had duplicated all occurrences of the \ character.
So when I compiled the STG into HYP, this error was propagated.

Once I understood the problem, the line became:

Code: Select all

strcat( path, "\\*.*");

and I knew what was happening.

But it was good that happened because I was able to fix the HYPs and re-up them to the other thread. All's well that ends well. :cheers:


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 1 guest