Search Results

Showing results 1 to 40 of 1000
Search took 0.14 seconds.
Search: Posts Made By: Ancient Dragon ; Forum: C and child forums
Forum: C 8 Hours Ago
Replies: 4
Views: 5,620
Posted By Ancient Dragon
Here are just a few suggestions:

line 46: >> gets(str);
Never ever use gets(). What will happen if I enter more characters than the buffer can hold? Answer: Seg Fault. Use fgets() instead...
Forum: C 1 Day Ago
Replies: 1
Views: 101
Posted By Ancient Dragon
Start here:

#include <stdio.h>

int main()
{
// your code goes here
}
Forum: C 1 Day Ago
Replies: 3
Views: 328
Posted By Ancient Dragon
call malloc() to allocate memory before line 67.
Forum: C 1 Day Ago
Replies: 1
Views: 123
Posted By Ancient Dragon
Post the code that shows the error.
Forum: C 2 Days Ago
Replies: 3
Views: 81
Posted By Ancient Dragon
I wrote != (not equal to), which is the opposite of == (equal to).
Forum: C 2 Days Ago
Replies: 3
Views: 81
Posted By Ancient Dragon
You mean like this?

char c;
while( c != '\n' )
{
// blabla
}
Forum: C 4 Days Ago
Replies: 1
Views: 167
Posted By Ancient Dragon
To get a random number between 1 and 6: int num = 1+ (rand() % 6). The rest of that function you should be able to do yourself.
Forum: C 4 Days Ago
Replies: 6
Views: 271
Posted By Ancient Dragon
There are only two ways to get it like that:

Pay someone to write it for you. That will cost you some $$$
Learn to write it yourself.


I have not the time to write it for you.
Forum: C 4 Days Ago
Replies: 6
Views: 271
Posted By Ancient Dragon
Writing such a program is no trivel matter. If you are a beginner in C language then you have no business attempting that. Instead, learn the basics of the language first, then once you are...
Forum: C 5 Days Ago
Replies: 7
Views: 264
Posted By Ancient Dragon
Not surprised by your problem because the code you posted won't compile. You can't run a problem that is just full of crap.
Forum: C 6 Days Ago
Replies: 6
Views: 271
Posted By Ancient Dragon
It's pretty simple, just create an infinite loop. Inside the loop get current time ( time() in time.h ), convert to tm structure ( localtime() ), then just print the hour, minute, and second).
...
Forum: C 6 Days Ago
Replies: 1
Views: 223
Posted By Ancient Dragon
You don't need either of those two programs. To edit a text file just completely rewrite it. Open the original for reading, open a new file for writing, in a loop read a line from the original...
Forum: C 6 Days Ago
Replies: 7
Views: 317
Posted By Ancient Dragon
If you are using VC++ 2008 (or earlier) you can easily view the entire contents of that buffer without resorting to putting that kind of debug code in your program. Not sure if Code::Blocks will do...
Forum: C 6 Days Ago
Replies: 1
Views: 172
Posted By Ancient Dragon
>>I'm new to using Visual Studio. I'm currently using VS .NET 2003 on Vista

Upgrade to VC++ 2008. You can get free Express version. CLR and MSDN was changed quite a bit since 2003.

Not sure...
Forum: C 6 Days Ago
Replies: 1
Views: 229
Posted By Ancient Dragon
OMG! Is that some sort of failed attempt to sort the array??? There are lots of sorting algorithms, had you bothered to google for any of them. Like these...
Forum: C 6 Days Ago
Replies: 2
Views: 256
Posted By Ancient Dragon
If you are using MS-Windows then use win32 api console functions (http://msdn.microsoft.com/en-us/library/ms682073%28VS.85%29.aspx).
Forum: C 7 Days Ago
Replies: 2
Solved: dynamic array
Views: 229
Posted By Ancient Dragon
Function add() -- second parameter must also be passed by reference. You are just passing the pointer by value, which does nothing in main()'s copy of the pointer. Note the second parameter should...
Forum: C 7 Days Ago
Replies: 3
Views: 328
Posted By Ancient Dragon
line 67: amic is an ininitialized pointer.
Forum: C 7 Days Ago
Replies: 7
Views: 317
Posted By Ancient Dragon
>>for(int i = 0; i < strlen(buffer); i++)

buffer is NOT a null-terminated string, so strlen() can/will not work with it. The buffer you created is just an array of characters, and memset set each...
Forum: C 8 Days Ago
Replies: 2
Views: 230
Posted By Ancient Dragon
you can not convert an integer to character array like you tried to do. Use sprintf() instead
sprintf(t, "%ld", i);
Forum: C 8 Days Ago
Replies: 5
Solved: char in c?
Views: 289
Posted By Ancient Dragon
1) you failed to read Aia's comment.

2) The printf() statement is incorrect. %s is for a charcter array, shape is not a character array. What you want os %c
Forum: C 8 Days Ago
Replies: 1
Views: 199
Posted By Ancient Dragon
First you have to define the term "microarray data". We are programmers, not biologists.
Forum: C 8 Days Ago
Replies: 5
Solved: char in c?
Views: 289
Posted By Ancient Dragon
>>if (length=breadth)

you are using the wrong operator -- use == boolean operator instead of = assignment operator.

>> shape= 'square';
Two problems with that line

All strings (two or...
Forum: C 8 Days Ago
Replies: 7
Views: 317
Posted By Ancient Dragon
cout only works with text buffers -- your buffer contains binary information and most likely the very first byte is a 0.
Forum: C 9 Days Ago
Replies: 3
Views: 213
Posted By Ancient Dragon
>>is it a standard one?
Yes -- all compilers are required to implement it like that. Here (http://en.wikipedia.org/wiki/ANSI_C) is info about ansi c standards

>>the array name cannot be changed...
Forum: C 9 Days Ago
Replies: 10
Views: 449
Posted By Ancient Dragon
Oh I see -- I guess I misunderstood. You would have to sort the list after it was finished. When sorting linked lists just exchange the actual data, not the entire nodes, to preserve the link...
Forum: C 9 Days Ago
Replies: 3
Views: 235
Posted By Ancient Dragon
If all you want to do is run that program once when what' the point of making the text file into a fixed-length records? Such a scheme would limit the usefullness of your program.
Forum: C 9 Days Ago
Replies: 2
Views: 251
Posted By Ancient Dragon
where is your code? No one here will write that program for you.
Forum: C 10 Days Ago
Replies: 10
Views: 449
Posted By Ancient Dragon
Change AddWord() to add the new node in ascending or descending order. Then you won't have to bother about sorting later.
Forum: C 10 Days Ago
Replies: 5
Code Snippet: Linked List
Views: 375
Posted By Ancient Dragon
1) remove conio.h -- its non'standard and not implemented by very many compilers. Code snippets should not use compiler-specific stuff.

2) delete all those global variables on lines 12 and 13. ...
Forum: C 10 Days Ago
Replies: 3
Views: 235
Posted By Ancient Dragon
You don't have to store all the lines, just the two lines that you want to compare. Sequentially read the file, counting lines as you go along then save only the two lines you want to compare.
Forum: C 10 Days Ago
Replies: 10
Views: 449
Posted By Ancient Dragon
delete line 56 -- it does nothing.
Forum: C 11 Days Ago
Replies: 10
Views: 449
Posted By Ancient Dragon
Why did you use fgets() instead of fscanf()? fgets() gets the entire line without regard to spaces, which is not what you want. Look at the simple code I posted, it does what you need. All you...
Forum: C 11 Days Ago
Replies: 14
Views: 616
Posted By Ancient Dragon
Yes. Its not really all that big a deal since the program has reserved space for the data anyway. Even though you have the arrays declared in if statements the compiler will allocate memory for all...
Forum: C 11 Days Ago
Replies: 10
Views: 449
Posted By Ancient Dragon
>>The program is supposed to take in a file provided through standard input
That means get the name of the file from standard input, not the lines of the file. You have to open the file and read...
Forum: C 11 Days Ago
Replies: 1
Views: 276
Posted By Ancient Dragon
Modern 32-bit compilers to not support that header file because it was intended for 16-bit MS-DOS 6.X and earlier operating systems. The alternative is to use win32 api functions OpenFile() to open...
Forum: C 11 Days Ago
Replies: 14
Views: 616
Posted By Ancient Dragon
Yes it does work.



Read the file into the array just like it was any other normal text file.
Forum: C 11 Days Ago
Replies: 14
Views: 616
Posted By Ancient Dragon
>>Is there anyway to achieve this?
No because the #inc lude directive is processed at compile time, not runtime.
Forum: C 11 Days Ago
Replies: 3
Views: 319
Posted By Ancient Dragon
First you need a 2d array to hold the final strings. Then a row counter, a column counter, and a comma counter. In a for loop copy each character in the original array into the current row/column...
Forum: C 12 Days Ago
Replies: 7
Views: 393
Posted By Ancient Dragon
You are asking about some pretty complex code, which I am not prepared to provide to you. Its been 15-20 years since I did worked with that. Your best bet would be to study some of these google...
Showing results 1 to 40 of 1000

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC