Thank you for your advice!
Bigturtle, the idea is indeed to have a rather big input file in the end, so I need to know which numbers represent which parameters.
Any function of the program will scan the parameters in the input file and store the values that it needs in local variables.
I have read the man files on strcmp (or strncmp) and this is what I have. It compiles but gives segment violation when running. I suppose...
User Profile
Collapse
-
Thank you for your help!
I now use getline to read in every line one by one. But how do I evaluate the value of the first part of the line? For instance, if the first part is "Temperatur e", how do I put the second part of the line (the actual numerical value of the parameter) in a variable "B".
...Code:double B; char xxx[100]; variable[99] = '\0'; /* or just assign xxx[100] =
Last edited by AdrianH; May 9 '07, 03:48 PM. Reason: Please use [code][/code] tags for greater readability.Leave a comment:
-
handling input and output data in files
Hello,
I want to create an input file for my program in which I store all of my input data (constants etc.).
Something of this kind:
------------
Input parameters
------------
boxlengthX 1.0
boxlengthY 1.0
boxlengthZ 1.0
radius (nm) 10
Temperature (K) 298
etc.
which scan function... -
Thank you for your comment!
I did what you indicated, replacing the getline function using scanf as a test.
Now it sometimes skips lines in the middle of the input file as well, even though they all contain 12 variables. However, the last line is only evaluated once.
The input file is actually the result of an other program that puts these 12 variables on a line, followed in the end by \n, so I guess there should be no...Leave a comment:
-
getline and C
Hello,
I am new at computer programming and I am having trouble using getline() in C.
I use an input file that contains 12 variables on every line.
From the printf statements below, I notice that scanf, although risky, does the job correctly.
However, getline skips the first line from the input file and evaluates the last line twice.
Do you have any idea what I am doing wrong?
Thank... -
struct and C
Hello,
I am completely new to computer programming and I have trouble using structures in a correct way in a C program.
After testing several components of the program, the problem is basically this:
#include <stdio.h>
main()
{
/*define structure with containing three coordinates*/
struct point {
float x;
float y;
float z;
};...
No activity results to display
Show More
Leave a comment: