Oh, and I'm running Windows, but the computer it has to compile on is SunOS I believe.. might be Linux, not 100% sure.
Type: Posts; User: TitoMB345
Oh, and I'm running Windows, but the computer it has to compile on is SunOS I believe.. might be Linux, not 100% sure.
Well, I have it take the start time before the getInput() function runs, and getInput() waits for input from the keyboard, so I tried waiting a couple of seconds, and still, nothing came up. I'm not...
Okay, so my quick exploration into clock() sent me on this path:
clock_t start, end;
...
int main() {
int numrows = 0, numcols = 0;
Ahha, I knew it was something simple..
Now, is there a way to have it go into milliseconds or anything lower than seconds? The function runs so fast it usually just says 0...
Hey guys, I was wondering if anyone could help me with a quick question.
I need to find a way to print the time it took for a program to run in seconds. I don't have much experience with time, but...
So, reading through my C text, it seems somehow I will have to use fseek(). I think my original approach to the problem was incorrect. I am going to start over and try another way.
Yeah, I still havent been able to find a way to do this. It seems nearly impossible without the ability to store all the data in the program, it would be easy if this were possible. But I am not...
Another quick thing I need some assistance with is alphabetizing a file created from the program. So, the program will create a file like:
Namath Joe
Lugo Julio
Favre Brett
Jordan Michael
...
Okay, one more quick question now too:
How can I have the program wipe the file first before writing to it?
int main() {
FILE *list, *output;
char first[MAX], last[MAX],...
Ah, nevermind, I had a stupid error.. in my FILE definition for the output file I forgot the * before it. So when I did something like
output = fopen(filename, "w");
Where filename was equal...
Hey guys, I've got a quick, and seemingly simple, question for you all. How would I write a function that would dynamically write output to a file? For example, say the program is to take 2 words...
Ahha, that did it. I could have sworn I had the code to alloc the memory in there before.. must have lost it in my many attempts to fix the code after the first run through. Thanks again!
No ideas?
Hey guys,
I am in the midsts of writing code that involves managing two queues of names, and having the ability to call one name from the queue, and then deleting it. For some reason, I can't...
Thats what I tried now, but the conclusion I've come to is that the sscanf and fscanf functions in the library on our servers are just incorrect. There is no other explanation.
Hmm, well I put that in directly and it gave me a seg fault, and then I noticed there was no 's' after the first [^,] thing, so I added it, and the seg fault went away, but the results were still not...
Hey guys,
I have run into a problem using fscanf to properly read a file.
struct menu {
int calories, price;
char name[MAXNAME], type[MAXNAME];
} dish[MAXDISH];
Hey, thanks for the help! It's funny though, because we figured out what we had to do about 2 minutes before you posted it! I really appreciate the help though.
Hey guys, I am stuck with another C programming problem that I can't seem to get around.
The problem I am having is trying to read a file of words, like a story, into an array of strings. What...
Hey guys, thanks again for the help.
You are right, the assignment says to assume there would be no more than 1000 ints entered. So if they enter 1000 ints, the character array would overflow...
Actually, I ended up using Recursion to fix it!
void sepArrays(char input[], int array[], int *pos) {
long num = 0;
char *p;
num = strtol(input, &p, 10);
if (num != -2) {
Okay, so my latest thought would be somehow using recursion to keep looking for ints until the input is over... hmm.
Hmm, okay, so I have strtol() convert the first appearance of an integer into a long... how do I go on from there? How do I tell the program to start looking again passed the integer? The pointer I...
Yes, it is always a single line of numbers input by the user.
I just need the line to be separated into an array of ints with each index at one. I will try what Salem mentioned, thanks!
Hey guys, first time poster!
I had a quick question for the masses about a program I am writing: I need to take the input from the user at the keyboard that contains all integers, and then store...