Forum: C Mar 12th, 2007 |
| Replies: 27 Views: 5,768 Wow you've obviously got superior reasoning....:lol: Anyway, I guess I'll starting paying attention to such menial considerations. Regarding the programming suggestions I mean. Lol. |
Forum: C Mar 12th, 2007 |
| Replies: 27 Views: 5,768 I'd really appreciate a link to a standard specification either for C (?) or for Daniweb, seriously.
Ok, it does not exactly work like that, however, please inform me on how returning 1,... |
Forum: C Mar 12th, 2007 |
| Replies: 27 Views: 5,768 Well if he is learning then he is a beginner. So what is your point? |
Forum: C Mar 12th, 2007 |
| Replies: 27 Views: 5,768 Well considering the context of this debate, any considerate person would clarify such a deceiving addition.
Yeah.... well it is a good thing it is your opinion. :lol:
Lousy code?... |
Forum: C Mar 12th, 2007 |
| Replies: 27 Views: 5,768 Umm.... Lol.... I do make sure. :lol: |
Forum: C Mar 12th, 2007 |
| Replies: 27 Views: 5,768 Yeah, the only compiler I have access to is on a Windows workstation, which I'm not allowed to transport any data electronically. So I simply copy from the compiler IDE to the code posting. But... |
Forum: C Mar 12th, 2007 |
| Replies: 27 Views: 5,768 Here is another example program that might help you:
http://www.daniweb.com/code/showsnippet.php?codeid=661 (http://www.daniweb.com/techtalkforums/../code/showsnippet.php?codeid=661) |
Forum: C Mar 12th, 2007 |
| Replies: 49 Views: 10,372 Well all be.... you're right Joe! Here is the oh so massive change ;)
for (int i=0;i<max_value;i++) {
x = rand() % row;
y = rand() % col;
if (array[x][y] == 0)
array[x][y] = id;
... |
Forum: C Mar 12th, 2007 |
| Replies: 27 Views: 5,768 Then I suggest you get a new compiler ;) Lol. |
Forum: C Mar 12th, 2007 |
| Replies: 27 Views: 5,768 Here is a program that might help you: http://www.daniweb.com/code/snippet660.html (http://www.daniweb.com/techtalkforums/../code/snippet660.html)
Good luck, LamaBot |
Forum: C Mar 12th, 2007 |
| Replies: 1 Views: 5,378 Here is just a simple program to sort two strings inputted from the user entered on the command line. |
Forum: C Mar 12th, 2007 |
| Replies: 27 Views: 5,768 Yeah.... the code I'd posted was an example. I indicated this when I said |
Forum: C Mar 12th, 2007 |
| Replies: 49 Views: 10,372 I hope I don't "burn my bridges" by adding this but here it is. I'd like to say one thing, in reference to Walt's solution code to another. Consider the following which would do the exact same thing... |
Forum: C Mar 12th, 2007 |
| Replies: 27 Views: 5,768 What happens if a string doesn't contain a character for ascii 97 to 97+strlen in its name? If strchr encountered a character not located in the string, it'll return NULL. What if the strlen of name1... |
Forum: C Mar 12th, 2007 |
| Replies: 27 Views: 5,768 It is not good practice to use strlen in a for loop, especially for loops that must loop many times because strlen iterates through the array of characters one-by-one every time called (i.e. every... |
Forum: C Mar 10th, 2007 |
| Replies: 49 Views: 10,372 Problem solved by Walt's code.
LamaBot |
Forum: C Mar 10th, 2007 |
| Replies: 49 Views: 10,372 Ok, keep the code I just said to changed, changed and try this.
void populate(int array[][col], int row_size, int col_size) {
int x, y;
for (int... |
Forum: C Mar 10th, 2007 |
| Replies: 1 Views: 1,359 Here is a list of Linux system calls, you might find something in there: http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html
Also, IF you're a Linux enthusiast I'd recommend getting a... |
Forum: C Mar 9th, 2007 |
| Replies: 49 Views: 10,372 When you cout the locations, try the following to see if it works then:
for (int i=0;i<=row_size;i++) {
for (int j=0;j<=col_size;i++) {....
This might be the reason you can only see around... |
Forum: C Mar 9th, 2007 |
| Replies: 3 Views: 1,084 Infraction's way works as well. Here is just a simple way to convert from double to char to accommodate the latter option:
char dblBuf[8];
sprintf(dbBuf,"%4.2f",solution);... |
Forum: C Mar 9th, 2007 |
| Replies: 3 Views: 1,084 Yes, it is called casting. Consider the following:
double d1 = 5.21;
int num;
num = (int)d1;
printf("%.2d", (double)num);
Output = 5.00 |
Forum: C Mar 9th, 2007 |
| Replies: 49 Views: 10,372 One last thing, I don't think you wan the following:
if(array[x][y]!=0)....
Reason; because you want to populate positions in the array aren't already occupied therefore you'd want to change... |
Forum: C Mar 9th, 2007 |
| Replies: 7 Views: 1,424 Well that depends I suppose. What common mechanisms do teams have, yet are implemented differently? Such as each team usually practices at certain locations, which is might be useful information. You... |
Forum: C Mar 9th, 2007 |
| Replies: 7 Views: 1,424 I think that is a cool project, btw. Anyway for the division, teams and league I'll give some fastly written code that might spark some ideas in that creative head of yours. Here is some example... |
Forum: C Mar 8th, 2007 |
| Replies: 21 Views: 5,636 You might want to take the amount entered by the user, check to see if the amount is greater than what the coins are worth and skip that coin if it is. Once you reach the coin that doesn't exceed the... |
Forum: C Mar 7th, 2007 |
| Replies: 49 Views: 10,372 Walt, when I'm using for loops, my C++ compiler allows me to declare and initialize a variable within a for loop. I don't know if that is valid standard C syntax though. Here is a link briefly... |
Forum: C Mar 7th, 2007 |
| Replies: 49 Views: 10,372 Yeah that is probably the problem. An easier way to confirm this is just declare i and j as integers before executing the for loop. Sometimes when I'm writing a reply post, another post gets posted... |
Forum: C Mar 7th, 2007 |
| Replies: 5 Views: 1,032 Yes, to implicitly set the functions argument list to none, you use void. you use void to say there is no return type, or return therefore.
Good luck, LamaBot |
Forum: C Mar 7th, 2007 |
| Replies: 2 Views: 940 Referring to my previous post reply, I'll give an example of the distinctions and commonalites. Each team could have uniforms. The uniforms for each team have a basic structure yet have a different... |
Forum: C Mar 7th, 2007 |
| Replies: 2 Views: 940 I'll provide a ascii diagram of how you might implement this and a following explaination:
[ class_league ]
[ class_division ] [ class_team ] [ class_player ]
... |
Forum: C Mar 7th, 2007 |
| Replies: 12 Views: 2,384 I wasn't aware of the issues involed when casting a void pointer returned by malloc. Note the hesitation.... meaning I knew it wasn't an illegal instruction that doesn't mean I claimed that it is... |
Forum: C Mar 6th, 2007 |
| Replies: 12 Views: 2,384 Well... I know 'char *data2=(char*)malloc(strlen(data));' isn't an illegal initialization as shown here: http://www.space.unibe.ch/comp_doc/c_manual/C/FUNCTIONS/malloc.html Perhaps it is you4... |
Forum: C Mar 5th, 2007 |
| Replies: 12 Views: 2,384 Try to allocate the memory using malloc like this:
char *data2=(char*)malloc(strlen(data));
The above simply casts the pointer returned by malloc to the memory allocated to a type char.
... |
Forum: C Mar 5th, 2007 |
| Replies: 49 Views: 10,372 Here is the modified code:
#define rows 7
#define columns 10
#define max_total 12
#define id 1
void array1( int (*multi_d)[columns])
{ |
Forum: C Mar 5th, 2007 |
| Replies: 49 Views: 10,372 As mentioned above, I thought you wanted a random number with a maximum of 12 objects in the array. My original method uses the fact that it is possible to overwite the values whose coordinates are... |
Forum: C Mar 5th, 2007 |
| Replies: 49 Views: 10,372 In his sample code it had a constant using MAX in its identifier. I took it as it had a maximun but not a minimum, which is why I specifically wrote it this way as to indirectly have the number of... |
Forum: C Mar 5th, 2007 |
| Replies: 49 Views: 10,372 You don't use it with rand, you use it with srand - which is used to seed rand. If you use just use rand without seeding rand, every function call it'll produce the same values for x and y, that is... |
Forum: C Mar 5th, 2007 |
| Replies: 5 Views: 1,456 calloc will allocate 5 node structs. p will point to the first of the five elements. On the second loop, last will be assigned the new allocate 5 struct node objects, but then last will be assigned... |
Forum: C Mar 5th, 2007 |
| Replies: 49 Views: 10,372 multi-d[rows][columns] = {{0},{0}};/*Initialize all elements to zero*/
This will initialize the first and second row's first element's to the value of 0.
Since it IS necessary you use a... |
Forum: C Mar 5th, 2007 |
| Replies: 49 Views: 10,372 You're right. I'll keep that in mind. Darn my lack of common sense. |