Yeah that worked. I'm sure I tried just using a dot initially but I guess not. Another quick question, if in the struct I had a variable 'value' which was an array of 4 ints, would that be accessed...
Type: Posts; User: fxtdr79
Yeah that worked. I'm sure I tried just using a dot initially but I guess not. Another quick question, if in the struct I had a variable 'value' which was an array of 4 ints, would that be accessed...
I have a typedef struct as follows:
typedef struct {
float x, y, z;
} point3d;
Then I create the following:
Thanks for the tips guys, I managed to get it working correctly.
I have a data structure declared like this:
typedef struct {
double x;
double y;
} xyPoints;
Then I created a pointer like this:
Thanks, that seems to be the exact issue I was wondering about.
I'm trying to do something for an assignment and we have to use a float variable. I was getting really messed up results and I couldn't figure out why so I wrote this program just to test some stuff...
I re wrote the entire program to use only fgets and sscanf and it works fine. Couldn't get it to work correctly with a switch statement so I changed that to if else if statements and it works fine. ...
Do you know how to correct eh fgets/sscanf code I put in the top post to get it work correctly ?
If 4 valid entries aren't entered it goes into the else loop which should clear the entire input buffer since it loops around until it reaches a '\n' so I don't see how '\n' would be getting left in...
Here is more complete code:
A valid entry would be something like: 856 John McSmith 45.76 (spaces between each item and hit enter when done).
Invalid entries would be something like: "John...
I've read various google links and everyone seems to have a different way for dealing with formatted input in C and non of them seem to work for me so I'm looking for any suggestions. I want to...
Those are both incorrect (for me anyways) and all give segmentation fault errors. I even tried changing char *words[] to char **words[] and I just get different errors using that.
I have an array of pointers that point to arrays of characters and what I'd like to do is access the 4th letter in the 3rd word and change it. I've tried tons of combinations but I can't seem to get...
I'm trying to resize an array using realloc and it's telling me that the size is invalid but I'm not sure why since I'm using sizeof to get the correct size. Any ideas?
#include <stdio.h>...
I have something that works like this
int main()
{
int currentNumber;
int currentUnit[3];
int checkInput;
This just goes right over my head, I'm sorry but this makes no sense to me.
while ( 1 ) // what does that even mean. How would that fit into my code, 1 is never going to change so it's never...
That's the heart of my question. How do I clean up after the user? How can I stop the infinite loop when they enter bad input? That's EXACTLY what I'm asking you guys. How do I clean up bad input...
So the jist is no I can't use scanf I'm going to have to use fgets and write a parser for it since I know there is going to be purposely bad formatted entries. I feel like all I do in C is code...
That's probably the problem, I don't really see why I can't use scanf to do what I want since it basically does exactly what I want except I can't clear the error when I enter hh88. Using fgets...
I was originally told to use getchar() then to use scanf() now to use fgets() so I don't know how many more inputs C has that I shouldn't be using because they don't work but I'm waiting to be told...
I have 2 issues with this the first is that from the link you posted they say
char *fgets(char *restrict s, int n, FILE *restrict stream); I don't want to read from a file, I want the input to be...
First, thanks for all the help with my other questions, learning a lot fairly quickly. I read basically when you get an error from input, the error stays until you clear it and enters an infinite...
Yeah, and if you saw the response I got it was go ask this question in a real computer forum, which is here, which is why I reposted the same question, pretty much word for word before deleting the...
Thanks, I got it working using something like this
testForEOF = scanf("%d%s", &number, unit);
while (testFor EOF > 0)
{
...
}
I've written the following code and I want it to keep looping around collecting input (only asking the question once at the start) until the user uses EOF (aka ctrl+d) to "say I have no more input". ...