LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C....Fun with strings :( (https://www.linuxquestions.org/questions/programming-9/c-fun-with-strings-174423/)

Scrag 04-25-2004 12:42 PM

C....Fun with strings :(
 
Im writing a C program, right now I have a loop that lists files in a dir, one by one. With each file being listed, I'd like to concatenate the html code:

<img src="/icons/file.gif" alt="FILE" /> <a href=" ********Before the file name

and

"></a> ********after the file name.

So file string start is:
readme.txt

then after is:
<img src="/icons/file.gif" alt="FILE" /> <a href="readme.txt"></a>

I've tried strcat() among other things and can get ending portion concatenated to filename, but cant get <img src="/icons/file.gif" alt="FILE" /> <a href=" concatenated to beginning of filename. im also having trouble becase there are " in the string I need to work with.

Any Suggestions??

Thanks!!

jlliagre 04-25-2004 12:53 PM

prefix the " with a \

Scrag 04-25-2004 01:18 PM

Thanks,

That takes care of one problem. Also...Would anyone have an idea where to start or have a code example of how I could append / concatenate the 2 pieces of html code to a string /file name?

itsme86 04-25-2004 02:12 PM

Try this:

sprintf(buffer, "<img src=\"/icons/file.gif\" alt=\"FILE\" /> <a href=\"%s\""></a>", filename);


All times are GMT -5. The time now is 02:54 PM.