Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...My thanks to the contributors who freely share their knowledge and enthusiasms. This forum restores some measure of my faith in human nature..."

Geography

Where in the world do Tek-Tips members come from?

How do I extract all strings from a C file?

ddeham (Programmer)
19 Oct 06 19:49
Hi,

I need to get my C program translated from English into Spanish. In order to do so, I need to extract all of the strings out of my 35,000 lines of C code into a separate file so I can send it off to be translated. How can I quickly and easily extract the strings out of a C code file? I tried using xstr, but it didn't extract all of the strings. It left a lot of them in the source file. Please help!

Thanks,

Dan
Salem (Programmer)
20 Oct 06 7:50
> How can I quickly and easily extract the strings out of a C code file?
Use xstr of course, after you've fixed your code to be xstr friendly.

I can only guess from your vague information "It left a lot of them in the source file" what you're seeing.

Why don't you post a 5-line example source file which shows two examples of strings, one which xstr finds, and one which xstr doesn't.

My guess is that the strings it misses are buried inside macros, or other horrors, and xstr wisely leaves them alone as being "too difficult".

--

ddeham (Programmer)
20 Oct 06 14:45
Here's a code fragment where the strings weren't extracted:

CODE

// Write new flash variables
if (SaveUserParameters(&mds, sizeof(mds)) != 0)
    sprintf(silentstring, "Programmed correctly");
else
    sprintf(silentstring, "Programming failed");
SilentHistoryQueue();
WriteConfigRecord();
strcpy(statusstring, "ReBooting - Wait 5 seconds - Then Refresh");

Here's a code fragment where the strings were extracted:

CODE

sprintf(silentstring, (&xstr[1644]), MotorCurrent, Old_Motor_Current);
SilentHistoryQueue();
sprintf(FiveSecString, (&xstr[1714]));
FiveSecTime = TimeTick;
FiveSecHistoryQueue();
xwb (Programmer)
21 Oct 06 11:08
Easiest way is to write a program to do it.

for each file
1) Ignore all // and /* */ comments
2) Look for ".  When you find another " which is not preceded by \, save it in a file

It is actually easier than you think.  Probably take half a day to write (the most difficult part is navigating the directory structure and getting all the source files) and a few minutes to run.


Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close