Forum: C 5 Hours Ago |
| Replies: 21 Views: 409 Yes, I did adopt it into my code. I kept the opening { and the closing }, in between I used the delete key. |
Forum: C 8 Hours Ago |
| Replies: 2 Views: 58 You missed to read the rules of the forum. We don't give any code away without you posting what you have done to show effort. |
Forum: C 13 Hours Ago |
| Replies: 21 Views: 409 Now, that you're better equipped with knowledge, let's take a look again at that scanf("%[^\n]s",&str1);. Narue told you already about the scanset and the extra s, however, the & has not been... |
Forum: C 1 Day Ago |
| Replies: 21 Views: 409 I do not know what you mean by "did it require three senior posters calling this person down...", but if you are troubled by the amount of feed back those two "misguided" posts have produced, perhaps... |
Forum: C 1 Day Ago |
| Replies: 21 Views: 409 It is understandable that most code posted in this forum are amateurish, but promoting the use of undefined behavior by the use of fflush(stdin) wins the contest.
fflush() should be used only with... |
Forum: C 8 Days Ago |
| Replies: 4 Views: 265 We don't do homework. Read the forum rules. And what you believe or do not believe is irrelevant. |
Forum: C 11 Days Ago |
| Replies: 8 Views: 305 -ansi switch, all that it does is to support the C89 features and disable the GNU extensions that conflict with C89, but it doesn't mean that it will make gcc compiler to behave as a strict ANSI... |
Forum: C 17 Days Ago |
| Replies: 5 Views: 364 scanf("%f", &length);
length is an int, you are passing a float. Same with scanf("%f", &breadth);
Either you change the type in the declaration of length and breadth, or change the f to d in the... |
Forum: C 22 Days Ago |
| Replies: 4 Views: 307 Read the comments I added to your source code.
Of course if you were looking to assign the values of the structure poly p at declaration time, then it would have been:
struct poly p = { 45, { 1,... |
Forum: C 22 Days Ago |
| Replies: 9 Views: 368 If you would take a little time to understand the information I gave you via links, in the second post, you probably would have not need to ask that question. |
Forum: C 22 Days Ago |
| Replies: 9 Views: 368 Or up and down. It doesn't matter. It is undefined behavior.
If a plane doesn't have a pilot, it doesn't matter if people speculate about the capacity of fuel tanks to make the trip, or the... |
Forum: C 22 Days Ago |
| Replies: 9 Views: 368 Click here (http://www.daniweb.com/forums/post1048411.html#post1048411) and here (http://www.daniweb.com/forums/post1049104.html#post1049104). |
Forum: C 22 Days Ago |
| Replies: 6 Views: 443 Expressions has direct effects and side effects.
This expression, x = y; has a direct effect of copying the computed value of y assigning it to the location x.
x = a[i]; has a direct effect as... |
Forum: C 23 Days Ago |
| Replies: 4 Views: 320 I knew there was more to it than what you stated previously.
What you wanted to know is if a void function can be use as the stop control for a loop. And the answer is ... no. There's nothing for... |
Forum: C 23 Days Ago |
| Replies: 4 Views: 320 Yes, why do you ask? There must be something else you want to know. |
Forum: C 23 Days Ago |
| Replies: 2 Views: 237 Instead of out = fopen (out, "w");
it must be out = fopen ( filename, "w" ); where filename is a string with the path to the file you want to write.
Remember, when you use the "w" if the file... |
Forum: C 23 Days Ago |
| Replies: 6 Views: 443 Those two expressions invoke undefined behavior. Anything can be the result.
It is best if you write int main(), and return inside of main to comply with the standard. |
Forum: C 23 Days Ago |
| Replies: 3 Views: 308 There's not such a mechanism of translating C to Java, except for the most rudimentary and simple statements. Since both languages are different, all that it can be done is to understand what the... |
Forum: C 23 Days Ago |
| Replies: 4 Views: 308 Variable str is created when the function leer() is used. It is [1]destroyed when the function leer() is finished. You are returning a pointer to that memory that might or might not contain the... |
Forum: C 26 Days Ago |
| Replies: 5 Views: 463 The rules of this forum clearly explain that we do not give away code to posters that do not show proof of effort. Where's the code? Where is your effort in the matter? |
Forum: C 27 Days Ago |
| Replies: 6 Views: 385 Nope. More like:
struct amicable *record;
/* record must point to some memory before using it */
record = &a_struct_amicable_block_of_memory; /* can be done with malloc */ |
Forum: C 27 Days Ago |
| Replies: 10 Views: 374 :) segmentation faults occur when you are trying to access memory that you are not suppose to. e.g.
int *x; /* declares a pointer to int, the variable x is holding a random value which will be used... |
Forum: C 27 Days Ago |
| Replies: 4 Views: 252 When you are the original poster you'd see at the bottom, after the last post, the mark as solved title, in blue. Click on it. |
Forum: C 28 Days Ago |
| Replies: 10 Views: 374 char *c; is a pointer, again, it doesn't point to any proper memory allocated to it.
while(fgets(c, 600, fin)!=NULL)
Guess what you are trying to do there? Yeap! Trying to write to poor char *c... |
Forum: C 28 Days Ago |
| Replies: 10 Views: 374 For some, memory management in C, is a curse, nevertheless it is one of the strength of the language.
After allocating memory for it, remove any & in front of those pointers to string like... |
Forum: C 28 Days Ago |
| Replies: 10 Views: 374 struct REPLY *reply; is a pointer, anything you try to write to it it will produce a segmentation fault, since there's no memory allocated for it. |
Forum: C 28 Days Ago |
| Replies: 8 Views: 309 shakunni >Anyone know why this is the case?
A function must be called from another function block which could be the main function or one with a lineage to any main function.
Meaning that main()... |
Forum: C 30 Days Ago |
| Replies: 2 Views: 203 To save the transaction you are almost there.
int bal = 0; /* initialize balance to zero */
instead of bal = 0 + credit; replace for bal = bal + credit; or bal += credit; which is a shortcut. |
Forum: C 31 Days Ago |
| Replies: 2 Views: 221 |
Forum: C Nov 3rd, 2009 |
| Replies: 4 Views: 197 It was intended to be a hint, rather that a question to answer. |
Forum: C Nov 3rd, 2009 |
| Replies: 10 Views: 574 if( line == pattern)
That's a no-no, since line and pattern are strings and you can't compare arrays in that way.
Take a look at the string function strcmp() for that.
However, even if that would... |
Forum: C Nov 3rd, 2009 |
| Replies: 4 Views: 197 if (data_size == SIZE_32 ) {
* ( ((int32_t*)(new_node->data)) + index) = (int32_t) index*2 ;
* ( ((int32_t*)(new_node-> data)) + index) = (int32_t) index*3;
}
else {
*... |
Forum: C Nov 3rd, 2009 |
| Replies: 6 Views: 377 The controlling expression of a switch shall have integer type.
An array of chars will not do. |
Forum: C Nov 2nd, 2009 |
| Replies: 4 Views: 293 It doesn't matter, if she follows your advise she will get a square.
Then you'll learn nothing.
Some clue:
One loop inside another one as previously said.
Outer loop is the number of rows.... |
Forum: C Nov 2nd, 2009 |
| Replies: 2 Views: 248 First, you must understand what constitutes a string in C. It is a sequence of chars terminated with a '\0'.
So if I have this:
char fullname[] = "Jiminy Cricket";
and I want to split it into name... |
Forum: C Oct 30th, 2009 |
| Replies: 11 Views: 490 In the C89 standard, an array must be set with a constant. Which would not allowed what you just did.
int cantidad_frases = 0;
printf("Cuantas frases quieres escribir?: ");
scanf("%d",... |
Forum: C Oct 30th, 2009 |
| Replies: 2 Views: 276 fgets( student[count_s].name, sizeof (student[count_s].name), stdin ); |
Forum: C Oct 28th, 2009 |
| Replies: 2 Views: 214 Dear Sir/Madam:
Certainly, you made the right choice to select this forum to ask your C programming questions. Nevertheless, you skipped two important requirements that must accompany YOUR posting... |
Forum: C Oct 28th, 2009 |
| Replies: 7 Views: 524 void swap(int *num1, int *num2)
{
int tempvar1;
tempvar1 = *num1;
*num1 = *num2; /* learn the difference between num1 and *num1 */
*num2 = tempvar1;
} |
Forum: C Oct 27th, 2009 |
| Replies: 9 Views: 332 >If you can't find complete information about I/O in C from google, you're either an idiot or a liar.
Does it have to be so binary? |