5,237 Posted Topics
Re: Horribly broken, without code tags, unindented code no less. Apart from the broken printf call with the incorrect use of &, where is the increment to i to stop it being an infinite loop? | |
Re: Claiming "urgency" isn't our problem, just because it's your problem. [url]http://www.catb.org/~esr/faqs/smart-questions.html#urgent[/url] Spending a bit more time on composing your post is a good thing. [url]http://www.catb.org/~esr/faqs/smart-questions.html#writewell[/url] As is, being more specific about your problem. [url]http://www.catb.org/~esr/faqs/smart-questions.html#beprecise[/url] Eg, stating your operating system and compiler is a pre-requisite. > is there any way how … | |
Re: Some people might like the equality, but not the sum... [code] #include <stdio.h> int sum ( const char *p ) { int result = 0; while ( *p ) { result += ( *p++ - 'A' + 1 ) * 9; } return result; } int main ( void ) … | |
Re: [url]http://www.daniweb.com/forums/announcement8-2.html[/url] | |
Re: Use fgets() to read a line of input into a buffer, and check the result. Use strchr() to step from one delimiter to the next for example. Use strncpy() to copy string fragments, and make sure that a \0 is appended. Write your own version of strncpy() which automatically appends … | |
Re: I guess in your rush to spam multiple message boards [URL]http://www.tek-tips.com/viewthread.cfm?qid=1382444&page=1[/URL] with the same question, that you couldn't be bothered with simple courtesy of reading the posting guidelines on any of them. [URL]http://www.daniweb.com/forums/announcement125-3.html[/URL] | |
Re: Did you compile the debug code, or the release code? Did you disable the stack checking? - the diagnostic checks for stack overflow and/or stack corruption will dominate the time for small functions. In anticipation of your next question (how do I disable...), which version of Visual C++ are you … | |
Re: The array will still be passed as a pointer, no matter how you declare the function prototype / formal parameter. [INLINECODE] int GetValues (int a[MAX][MAX]) int GetValues (int a[][MAX]) int GetValues (int (*a)[MAX])[/INLINECODE] are all equivalent to one another. The first is easy to remember because it is simply copy/paste … | |
Re: Yeah, read this [url]http://www.daniweb.com/forums/announcement8-3.html[/url] Then edit your post so we can tolerate reading several thousand lines of code. Most people just ignore unformatted code, especially when there's so much of it. | |
Re: But if Linux is the OS running on your AT91RM9200 microcontroller, then there are no physical interrupts you can get access to. All user-mode programs live in a nice virtual world well away from the hardware. Unless you're talking about a kernel-mode device driver for some new device you've attached … | |
Re: For trivial programs, using clock() is like using a sun-dial to measure the speed of a Ferrari - "Why is it always 0, because it's too damn fast that's why!". Even the most optimistic precision (not accuracy) figures for clock() are at least 1M times slower than the clock frequency … | |
Re: > When someone who knows how to do it and is interested enough to help you comes along I read it yesterday, but I wasn't interested enough to answer. I read it again today, and I'm rapidly losing the will to care, what with all the bumping. > and finds … | |
Re: First random guess is you've reached the max number of open files you're allowed to have because you're not closing any of them. | |
Re: [URL]http://leto.net/docs/C-optimization.php#Gotchas[/URL] Read that bit first, then read it from the top. Then get yourself a profiler, run the program with meaningful data sets and ask yourself what it is that you really want to achieve. | |
Re: Perhaps start by saying what kind of program you're writing (console, GUI) and for which Operating System. It's really hard to make sensible suggestions without a decent level of background information. | |
Re: Essentially, it's about programmer choice. Originally, it went something like: Choose 'short' if you are concerned about the amount of storage taken up. Choose 'long' if you are concerned about the numeric range of the data. Choose 'int' if you are concerned about choosing the 'best' performance. The common assignments … | |
Re: > so this implies i've selected a worthwhile career. Being good (or at least competent) in C++ is a good career move. Before you decide on games, you'd better check the body count. [URL]http://en.wikipedia.org/wiki/List_of_commercial_failures_in_computer_and_video_gaming[/URL] | |
Re: Your question is so incoherent, all I can suggest is you paste the title into a search engine and start reading. [url]http://clusty.com/search?query=+Firmware+Over+The+Air&sourceid=Mozilla-search[/url] Plus, since you didn't ask a language specific question, it's off-topic in the C forum. | |
Re: Consider writing a version which runs on your PC first, to get all of the logic sorted out. With practice, you can do this well enough that the amount of work you need to do to get it to also do the same thing on your target is pretty minimal. … | |
Re: > GetDiskFreeSpaceEx() Dunno, but the 'df' command line program provides this information. If you could locate the Linux source for that program, perhaps you'll find out how it's done. > GetFileAttribute() Use the stat() API as described already. Should be good for regular files and directories. Remember, if it returns … | |
Re: > void main(void) Actually, it may be just fine as it is. > The microcontroller i'm using is PIC18F4620. This qualifies as a "freestanding" implementation. So long as main, or whatever the documented entry point is, is declared in a manner consistent with that implementation, then it should be good. … | |
Re: objc is for Objective C (sort of like C++, only different), yet your code looks like C++ proper. Which compiler are you using. If it's a command line compiler, paste your command line (or some compile logs if you're using an IDE). | |
Re: Well if you're calling it with a string constant to test it, eg [inlinecode] processString("hello|world");[/inlinecode] Then yes, it will fail because string constants are really constant, and the OS will halt your program if it even tries. Try something like [inlinecode]char test[] = "hello|world"; processString(test);[/inlinecode] If that isn't it, you … | |
Re: Are you using something like this to parse your XML? [url]http://search.cpan.org/~msergeant/XML-Parser/[/url] | |
Re: > practice.asm:6:End-of-File not at end of a line Open the source file in your text editor Go to the very end of the file and press the "enter" key. Save the file and try again. > And an output file: "a.out", I ran a.out and I got this message: The … | |
Re: If I said you need to convert each 8:8:8 colour into 3:3:2, would you have any idea what I was talking about? In other words, how much of the basics do you already know? | |
![]() | Re: > beqz $t5,exit #if char in array(i)=null 1. This test should be first 2. Should it be testing $t3, what you loaded from the array? > lb $t3,array($t1) Earlier, you assigned $t3 to be the lower bound, and now you're trashing it. ![]() |
Re: > Do you have any good idears to prevent it?help me please! Yes, you use fgets() in C, and getline() in C++ Both of which allow you to specify the maximum length of input. > C and C++ can not prevent the memory from overflowing Only if you use the … | |
Re: > i=(abcdario[g]+h)%27; The array is an array of structs, so you need something like [inlinecode] i=(abcdario[g][COLOR=Red].min[/COLOR]+h)%27;[/inlinecode] | |
Re: If the text file is large (and constant), and you need to do this a lot, then reading the whole file once to produce an index is worthwhile. The index being all the 'tell' positions for the start of each line, so at some future time, you can just 'seek' … | |
Re: Is there any online documentation for those syscall's, like 4 means print a string. Check that 5 (which I presume means 'read') does what you think it should do. My guess is you should be passing a buffer and a length to it. | |
Re: > i now get a segmentation fault when i run the code, and idea why that is and how i fix it Check the result of each strtok() call before trying to use it with strcpy(). If your input is mal-formed, then you will be in trouble. Also, note that … | |
Re: Perhaps start by reading said link, and some of the follow-on material. Then ask a specific question about your lack of understanding, on an appropriate forum. There is no "mind meld" technology where you can hope to know what someone else does simply by posting one line of cryptic text. … | |
Re: > Ok , ok so I failed to look at the datestamp of egemen's post -- three months old Yeah, a 3 month bump, which in itself began as a bump of a 3 YEAR old thread. I bet Jack knows how to spell his own name, regardless. #include <topic.h> … | |
Re: [url]http://www.daniweb.com/techtalkforums/announcement118-3.html[/url] The first won't even compile. The second trashes memory, so even if it "works for you", it's still wrong. | |
Re: Don't tell me that xor hack is in production code. [url]http://c-faq.com/expr/xorswapexpr.html[/url] | |
Re: Read this - [URL]http://www.daniweb.com/techtalkforums/announcement8-3.html[/URL] Then edit your post to improve the presentation. | |
Re: Can you post the corresponding C++ program as well. | |
Re: > mat1 = malloc(cols * sizeof(int*)); You've got the rows and cols mixed up in a couple of places. | |
Re: It's just simple maths [code] void process ( int a, int b ) { char var[10]; process( 0, 0 ); } [/code] You have a char array, so that's 10 bytes. Two integers - say 4 bytes each (total 8). Each call has a fixed overhead of several bytes (say … | |
Re: I suppose we'll have to wait a while longer for you to discover indentation as well as code tags :icon_rolleyes: Also, whether you intend this to be a C program or a C++ program (and not some random mix like it is at the moment). | |
Re: It's a meaningless question without some idea as to what your OS / Compiler / Hardware actually is. Unless you want something vague like [code] struct pixel { char r, g, b; } screen[ROWS][COLS]; void putpixel ( pixel p, int r, int c ) { screen[r][c] = p; } [/code] | |
Re: > i tried just iostream and it said cout was undefined... Well you also need to learn about namespaces as well. A crude "fix" is to convert [inlinecode]#include <iostream.h>[/inlinecode] to [inlinecode]#include <iostream> using namespace std;[/inlinecode] Better use would be only list the things which interest you. [inlinecode]#include <iostream> using std::cout; … | |
Re: Also, pick better subjects. [URL="http://catb.org/%7Eesr/faqs/smart-questions.html#bespecific"]http://catb.org/~esr/faqs/smart-questions.html#bespecific[/URL] You may as well have posted a blank message for all the good that "help" does. > [COLOR=green]Write a macros in which swap two number without using 3rd variable [/COLOR] Not this old chestnut. malloc and crusty macro hacks in C++ - I'm really not … | |
Re: [URL]http://msdn2.microsoft.com/en-us/library/Aa364418.aspx[/URL] Then lookup [URL="http://msdn2.microsoft.com/en-us/library/Aa364418.aspx"]http://msdn2.microsoft.com/en-us/library/aa364428.aspx[/URL] and finally [URL]http://msdn2.microsoft.com/en-us/library/aa364413.aspx[/URL] | |
Re: > int a[sizex][sizex]; The first problem is standard C++ doesn't allow variable sized arrays. Though some compilers offer it as an extension. > for(int i=1; i<sizex; i++) The second problem is that array subscripts start at 0, not 1. | |
Re: > hurry up [url]http://catb.org/~esr/faqs/smart-questions.html#urgent[/url] > does gcc compiler support graphics file ? No it doesn't - not by itself. So you're going to have to a) learn some netiquette b) say which operating system your gcc is running on. | |
Re: Look in your assembler reference for operations like 'rotate', 'shift' and 'and' | |
Re: [url]http://www.daniweb.com/techtalkforums/announcement8-2.html[/url] | |
Re: Maybe it's something to do with the fact that your array is an array of bytes, yet you load using eax (which is 32-bits IIRC). When you say it doesn't work, try to explain in more detail what you see and what you expect. I mean, the first value printed … |
The End.