As for the string to int problem, it hit me that I could just scan it as a double instead, multiply by 1000, and then treat them with %.0lf..
Do you think my teacher might think that this is a bit...
Type: Posts; User: kensing
As for the string to int problem, it hit me that I could just scan it as a double instead, multiply by 1000, and then treat them with %.0lf..
Do you think my teacher might think that this is a bit...
How can I create a new array that contains the different values of data[lineNo].value1?
For example, I have data[1].value1 = 50 and data[2].value1 = 50 and data[3].value1 = 100
I then want to...
I solved the problem with the above code :)
This is what I'm trying to do:
for(linjeNr = 1; linjeNr < LINJER_MAX && (data[linjeNr].hold1score + data[linjeNr].hold2score) >= 5; linjeNr++)
{
printf("%s\n",...
Ignoring invalid characters how?
Another major problem, which is underlying most of my other problems, is how to reference this array that I've built up:
struct kampdata
{
char...
Actually, yea, loads of warnings.. I should compile more often. I'll start from the beginning I guess, since this whole array subscript thing seems really tricky to me.
Since I'm taking these values from an array of strings, I should of course copy and parse them into an array of int's, so it would look more like this:
char new_string[lineNo];
int...
I thought your post made enough sense that I would be able to code it, but after moving on and returning to this problem several times, I'm still lost..
I tried implementing
char...
I've read a little bit about atoi() and some similar functions, but I can't get them working to resolve my particular problem..
I've scanned in some numbers in the thousands, and these have a dot...
Thank you - your responses have been very useful! :)
I got it all working now :)
Thus my last question related to this thread is this:
How do I choose to skip a piece of information in the file I'm reading from, using sscanf? For example, if my...
Of course, bingo :)
But how to access for example data.value1 in line 1?
I get the following error messages
test2.c:25:1: warning: data definition has no type or storage class
test2.c:25:1: error: conflicting types for ‘file’
test2.c:23:7: note: previous declaration...
I'm having trouble figuring out how to parse to data[lineNo] with sscanf. You don't have to do it for me, if you could just refer me to some explanatory text on the subject
Thank you in advance!
Thank you for the response, it seems very helpful, I'll look it over right now :)
I want to write a program that takes values from a text file, assigns them to different variables and then does different computations on those variables..
I've tried using fscanf/fgets and...