Forum: C Mar 30th, 2009 |
| Replies: 10 Views: 693 Ark's approach is much neater and most likely works. Your solution is very hard to read; the looping approach makes more sense. |
Forum: C Mar 30th, 2009 |
| Replies: 10 Views: 693 Purely for the sake of simplicity, I would go with this route (doesn't use a second set of variables):
int main( int argc, char *argv[] ){
int *numberlist, i, n, min, max ;
n = atoi(... |
Forum: C Mar 5th, 2009 |
| Replies: 4 Views: 1,662 For the purpose of adding a one dimensional array works well enough in representing a matrix. For more complicated operations though, it would likely be easier to define a matrix like int... |
Forum: C Feb 14th, 2009 |
| Replies: 6 Views: 447 He meant for you to look at your notes. Doesn't using the resources you have make sense? |
Forum: C Feb 12th, 2009 |
| Replies: 6 Views: 956 A semicolon can be useful in some preprocessor commands (probably some bizarre scenario), for example its perfectly valid in a #define statement. In this case we do need to know the compiler and its... |
Forum: C Feb 8th, 2009 |
| Replies: 22 Views: 1,273 My problem was not with your skill level because yes, I have been there. My problem was with your attitude. |
Forum: C Feb 8th, 2009 |
| Replies: 22 Views: 1,273 Maybe you should. Programming can be confusing and frustrating. If you can't deal with that even from a simple problem like this, maybe programming isn't for you. |
Forum: C Feb 8th, 2009 |
| Replies: 22 Views: 1,273 printf ("*",i);
What is that supposed to do? Read up on printf. Just a hint, it doesn't print "*" i times. And adding a tab before every *? I don't think thats what you want. |
Forum: C Feb 8th, 2009 |
| Replies: 22 Views: 1,273 It may seem strange at first, but try making the diamond yourself. Go through it slowly and see exactly what your thinking is on how to do it. Unless you can understand it yourself, you won't be able... |
Forum: C Feb 8th, 2009 |
| Replies: 22 Views: 1,273 I don't see you putting any spaces to the left of your rows. C won't automatically middle align it for you... |
Forum: C Feb 6th, 2009 |
| Replies: 4 Views: 911 Scanf can look simple, but it actually does a lot of work under the hood which obviously will slow down your code. Also, it can cause lots of problems if you don't know exactly how it is matching... |
Forum: C Feb 5th, 2009 |
| Replies: 4 Views: 911 fgets to get the string, strtok to tokenize it. To do this multiple times, just put your code inside the body of a loop. |
Forum: C Feb 3rd, 2009 |
| Replies: 7 Views: 398 But the correct thing to do, as "\n" is a pointer, not a char. Comparison between a char and a pointer to a char cannot be expected to work properly (who knows what "properly" even means here?) |
Forum: C Feb 3rd, 2009 |
| Replies: 7 Views: 398 EDIT: Sorry, Aia beat me to it. |
Forum: C Feb 1st, 2009 |
| Replies: 9 Views: 514 Can you explain that? I understand what Ancient Dragon did, but what about the "lock" concept? |
Forum: C Jan 31st, 2009 |
| Replies: 9 Views: 514 Do not use goto: in C applications. It is very bad coding practice (see spaghetti code (http://en.wikipedia.org/wiki/Spaghetti_code)). Instead, use control structures like conditional statements,... |
Forum: C Jan 30th, 2009 |
| Replies: 11 Views: 1,340 Then instead of setting the input variable to "18-2-21" (obviously not what csurfer intended), use fgets to get a line of user input. Also you could use sscanf() as long as you make sure to check its... |
Forum: C Jan 30th, 2009 |
| Replies: 11 Views: 1,340 You can use a tm structure for the date of birth, convert it with mktime(), and subtract that from time(). Then convert your answer back into a tm struct. |
Forum: C Jan 29th, 2009 |
| Replies: 12 Views: 1,634 A bubble sort but with the comparison flipped. |
Forum: C Jan 24th, 2009 |
| Replies: 16 Views: 696 What is the problem with using || ? It is a completely valid part of the C language. There might be some obscure way of doing the same comparison without it, but it would be useless to even try it. |
Forum: C Jan 22nd, 2009 |
| Replies: 5 Views: 387 You're right, that's different from:
char sudoku[] = { '0', '0', '1', '0', '0', '0', '0', '0', '9',
'6', '0', '8', '7', '9', '4', '0', '2', '0',
'0', '0', '9',... |
Forum: C Jan 19th, 2009 |
| Replies: 8 Views: 682 |
Forum: C Jan 19th, 2009 |
| Replies: 8 Views: 682 If you have to use array notation, also consider using a static variable instead of a parameter:
void enter(int *p_arr)
{
static int insert = 0;
printf("\nplease enter the number:");
... |