nevermind figured it out. Thanks!
Type: Posts; User: kuljule
nevermind figured it out. Thanks!
I'm sorry if I am seeming like I'm not listening. I am, but I am just really confused. Can you repeat where the seg fault is coming from? The program prints out the sentence but then after...
Its C Programming. That's the class. The thing about initializing it means that it won't work if its greater than that number. I want to be able to do this with any length of a string. I think...
using gets(sent) doesn't change the segmentation error. But how do I initialize i?
What do you mean i is not initialized? Isn't it initialized in the for loop?
Also, I here bad talk about using fgets. Why do people go against using it? What's the difference between fgets and...
I keep getting a segmentation error and i don't know why. Can you please help?
Thank you!
Here's the program:
insert
/*This program is suppose to take a sentence as input (in a string)...
Thanks!
how do you do that?
I mean why for certain values of j do you get z[j] being some huge number?
also when you do that. z[4] should be 25 or some integer. Why doesn't it give that?
I'm confused. What data is incomplete? And taking it out of the loop doesn't do anything. Do i have to take it out of both of the loops? Or out of the while loop completely?
what did you take out of the loop?
I don't get that. I get it doing the same thing over and over again in a loop having z[0] = 1 and then z[0] = 2 and so forth until z[0] = 10. Which i really don't get.
No cause its x[k] and y[j-k] so when j is 15, then k is j-9 which gives 6 so its x[6]*y[9] = z[15]
why do they have to be the same size? I'm just giving you what the assignment states. It states that x is size 10, y is size 10, and z is size 19.
Yeah i have to compute the z array for z[1], z[2], z[3], and so on until z[18].
And I can set them to zero after I get the program to do what I want it to do.
ok so now it executes but it gives a lot of numbers all randomly which i don't really understand why. I'm trying to write code to do the summation of x[k] * y[j-k] from k=max(j-9,0) to min(9,j) and...
nevermind. Thanks.
Yes that's true. I forgot about the semicolon. I had it right when using the terminal to compile it so it did compile. But the code you just wrote still says segmentation error.
Yeah I found that error but after I changed it, I still get a segmentation error. Any ideas?
My teacher told me to do it like that. And I also did it with the two fscanf statements again and i got a segmentation fault. Its like anyway I do it I get a segmentation fault.
----Julian
I'm confused.
Here is my whole program. Maybe you can see why i keep getting a segmentation error.
insert
#include <stdio.h>
int min_number (int x, int y)
{
actually i have one more question. How do I program it to keep scanning until the end of the file. I know I use EOF but when i put in
while(input_status != EOF && input_status2 != EOF)
it...
thanks! Yeah I should have known that. Now it works great! Thank you so much!
---Julian
ok so I did it like this:
input_status = fscanf(inp, "%d", &i);
input_status2 = fscanf(inp, "%f %f", &x[i], &y[i]);
and now I don't get a segmentation error but it prints out
0 0.007813...