Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Seperating some values in C

Status
Not open for further replies.

RAMBO29

Programmer
Jun 18, 2007
4
NL
Hi All;
This is my first time in C and I am writing a program for a machine.It works well and gives the ourput in this format

READOUT " 0.00 V, -0.04 A" /n

Is it possible to seperate the values 0.00 and 0.04 into 2 variables as doubles?It has to be exported in this format to draw a graph.

Thanks and regards
 
Whatever variables you used to print them out, you should also be able to use to pass to a new function. Could we see some code?

Sarah
-don't panic, I'm mostly harmless-
 
HI
The output is like this
REAREADOUT " -0.01 V, -0.04 A" /n
result(null)
VCSpplyVCSPPLY 16.0 /n
DOTDOT 256 /n
REAREADOUT " -0.01 V, -0.04 A" /n
result(null)
VCSpplyVCSPPLY 24.0 /n
DOTDOT 1 /n
REAREADOUT " -0.01 V, -0.02 A" /n
result(null)
VCSpplyVCSPPLY 32.0 /n
DOTDOT 1 /n
REAREADOUT " -0.01 V, -0.04 A" /n


So there only remains the seperation of the values -0.01 and 0.04 into two variables to be manipulated later.

Regards
 
Could I see the C code you used to print all this out? I don't know of a way to manipulate the actual output. Maybe someone else does.

By the way, when you do post the code up, be sure to use the code brackets like this but without the spaces: [ code ] code here [ / code ]

Sarah
-don't panic, I'm mostly harmless-
 
BTW Sarah, you can also put the [ignore][ignore][/ignore][/ignore] tags around text to print tags like [ignore]
Code:
[/ignore] without having to add the spaces...
 
Hi;
this is the output from machine.So the only inputs are commands sent to the machine like measure etc
 
Just to clarify -- is the output you've listed above from a program that you wrote (and have source code for), or are you trying to write a program that takes the output of an existing program (which you don't have source code for) and manipulate the data somehow?
 
Hi
This is the output fom a machine.So Its in this format.So i will have to say 'I am trying to write a program that takes the output of an existing program (which you don't have source code for) and manipulate the data somehow'.Because all I can do is to send commands to measure and this is how it responds.
Regards
 
OK, in that case, I believe this should work as long as the format of the output never changes:
Code:
char buffer[256];
float vNum, aNum;

/* Parse out lines starting with "REAREADOUT" into buffer. */

sscanf( buffer, "REAREADOUT \"  %f V,  %f A", &vNum, &aNum );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top