You cannot return multiple parameters from a function in C. You need either to return a struct that will contain both numbers, or use a sum function two times, one for each part.
Type: Posts; User: Tibo-88
You cannot return multiple parameters from a function in C. You need either to return a struct that will contain both numbers, or use a sum function two times, one for each part.
You are making computation on floats but returning ints from your function, therefore you get int values. Also you should really consider the comments from iMalc.
You are missing closing parenthesis line 52, 53 and 56. But you might have other problems :).
@nonoob : thanks for clarifying. But I might add that I would not advice taking the habit of using sizeof for computing string length, because when you switch to dynamically allocated strings, then...
"sizeof" is used to get the size of a data type, not a string. You should indeed use strlen(), which gives you the number of character in the string, excluding the null termination char '\0'.
...
You should not use the "putw" function (it is actually for me the first time to see that function).
As stated on the documentation, putw will write a "word" to the stream (file), but a word in...
This is not a question, this is a statement for a homework that I guess you are supposed to do. A question would be : "I don't understand what the "%f" means line 7" (for example). So if there are...
In C, in order to compare two values, you must use the "==" operator. The "=" operator is used for assigning values.
Then the second code has comparison, the literal translation would be : "is x...
I think a good place to start would be to read the datasheet, for both your components! (the other datasheet)
It seems like the problem is in the ASM part, but I don't remember enough of my ASM classes to help you with that.
Also it seems like only src2 is causing issue, because the following code is...
And your question is?
Could you show the working program with the input string set in the main? I tried to modify your program by setting the strings inside the program and it still leads to SEGFAULT in the ASM code part.
Take a look at this, I think it will help you.
The 9 and the 6 are the max length of the strings for each array. For example, in the first array, the biggest string is "Diamonds", which is 8 characters, plus the '\0' at the end => 9. Same for the...
In order to free the memory, you need a pointer to the address of that memory. So you always need to keep a valid pointer to a dynamically allocated memory, otherwise, this memory will be "definitely...
Take a look at the definition of a local variable on Wikipedia, I think it might help you.
If you notice in my previous post I put the destroyed word between quotation marks, because the memory...
I don't know Turbo C++, but I recall a lot of people saying that it is outdated on this forum.
But anyway, your problem remains the same, the local variable is "destroyed" when the program exits...
Enable the warnings in your compiler, you should see "warning: function returns address of local variable".
In fact you are returning the address of a local variable (k), which means that you can...
It is actually possible to make it without the "&&", but then the logic will be different.
I usually don't like to give so detailed answer, but you seem like you thought quite a lot, so I will...
First, I did not notice from the beginning, but take some time to read this page.
Then "x>y>z" is not good, that is not the proper way to do it. You have to compare if x>y AND x>z, by using the...
It is not a problem about single digit or double digit, it is just about the code logic. Again, what you want to check in your if and if else statement is for example x > y AND x > z which is the...
I'm sorry to disappoint you, but the logic is still not good. What if x > y but z > x? Then your program will print x, even if z is bigger than x.
I'm happy if you succeed to make it work, but it seems like the code you just posted is exactly the same than before :)!
Your problem is what you want, is for example to print the value of x if x is the biggest number, not only if x is bigger than y (same for the other conditions). So what you should test, is if x is...
That's why the code in the if block is executed by the child process, but not by the parent. Does it answer your question?