6,741 Posted Topics
Re: >extern unsigned char jetmap[][]; //missing subscript Yep, you're required to specify all but the first dimension, even for an incomplete type. You need it in the definition too: [code=c] /* .c file */ unsigned char jetmap[][3] = { /* ... */ }; /* .h file */ extern unsigned char jetmap[][3]; … | |
Re: What happens when you test it? What happens when you do a paper run? There won't always be someone sitting around to tell you that your code is correct, so you need to learn how to verify such things through a methodical process. | |
Re: >char* word; /* Temporary holding for each word */ >fscanf(fin, "%s", word); Pointers aren't magic containers for infinite data. You need to allocate space to word before you can write to it. In this case, there's little point in using a pointer unless you want to get fancy with single … | |
Re: >Is it correct to use the conversion specifier "d" with unsigned char in "fscanf"? Nope. You have no idea how your implementation of fscanf will work. It's especially dangerous to say you'll pass a pointer to a type of one size and actually pass a pointer to a type of … | |
Re: That doesn't sound like a bad thing to do at all. :icon_rolleyes: You might want to start reading The Old New Thing; there are plenty of horror stories about bad programmers who break the rules like that and screw up Windows for years to come. | |
Re: >unresolved external symbol "public: int __thiscall Object::returnCustomerID(void)" returnCustomerID is declared in Object (why?), not defined, and it's not virtual. I'm not surprised your linker is complaining that it can't find the definition. | |
Re: >// unecessary brackets Which can be used to introduce a new scope without adding a one-off function or doing something dumb like: [code=cplusplus] if ( true ) { // Stuff } [/code] You'd see it more in C prior to C99 where you want to restrict the scope of a … | |
Re: >Please Solve my some problems. Daniweb isn't a charity service. Don't expect anyone to do your homework for you, slacker. | |
Re: >snmpd.c:379:17: error: map.h: No such file or directory If you want to use the std::map class, it's in <map>, not <map.h>. All of the modern standard C++ libraries omit the .h extension. >snmpd.c:381: error: syntax error before 'namespace' What brand and version is your compiler? | |
Re: >Just wondering why remember me is checked by default. Defaults are usually determined by the expected "usual" behavior of users. I'm sure Dani determined that the majority of users would want to be automatically logged in when returning, so the box is checked by default. | |
Re: >which would be the best for a beginner with no prior programming experience It really doesn't matter. You'll learn how to program regardless of which language you choose, and the only way to figure out if you'll be comfortable for the long haul in learning a language is to start … | |
Re: >So, number[2] should give me the number I want Nope, it should give you the character that the value returned by function represents. Characters are represented internally by integer values. For example, in ASCII you can expect the letter 'A' to be represented internally by the value 65. If function … | |
Re: >Is it necessary for a compiler to follow ANSI standards To be strictly correct, it's the ISO standard. And yes, ideally your compiler should conform to the most recent standard as much as possible. However, complete conformance isn't necessary as most of the time the parts that aren't implemented are … | |
Re: >Pay attention to "but otherwise its type is implementation-defined" >and "or in some other implementation-defined manner" clauses... >Any comments? I always have comments. Let's break it down because you've quoted two separate things. The first quote is a slice of the following sentence from the C++ standard: [quote] It shall … | |
Re: >fin.open((char *)&str,ios::in); Eew, use c_str instead: [code=cplusplus] fin.open ( str.c_str(), ios::in ); [/code] You only have to escape a backslash in literals, so the following will work fine: [code=cplusplus] string str="C:\\Documents and Settings\\shankhs\\Desktop\\ccs\\Assignment CCS.txt" [/code] For input, you don't need to worry about escaping a backslash because it's already correct. … | |
Re: >my hw says it has an error in the code I count four errors. Since you mention homework, is this a homework question that [I]you[/I] should be doing instead of trying to get other people to answer? | |
Re: Please post your code inline or attach it if it's huge (1KB isn't huge, by the way). Not only is it irritating to have to go to third party file sharing services, it's terribly frustrating when the free service is unavailable due to server load. Most people won't bother to … | |
Re: >malloc() always returns a void pointer. You need to typecast it. C is kind enough to implicitly convert to and from pointers to void without the need for a cast. In fact, if you get into the habit of casting the result of malloc, your code is both more prone … | |
Re: This is how you read a file using getline: [code=cplusplus] while ( getline ( infile, buffer ) ) { // Process the line } [/code] | |
Re: find_if returns an iterator to the matched item, and for_each is retarded. ;) [code=cplusplus] CTest *it = b; CTest *end = b + 150; while ( ( it = find_if ( it, end, myCountIf ) ) != end ) { it->Set(); ++it; } [/code] | |
Re: >void trim(string[], int num) This should be: [code=cplusplus] void trim(char string[], int num) [/code] | |
Re: >please help me write a function which will return the last element in an unsorted list. How appropriately vague. When you say "last element", what do you mean? Do you mean the physical last item or the last sorted item? When you say "list", do you mean an array or … | |
Re: >while((ch==getche()) != 'd') == is comparison, = is assignment. | |
Re: >error C2660: 'Lottery::displayLottery' : function does not take 0 arguments >void displayLottery(int []); Looks like it takes one argument to me. You can't lie to your compiler, it doesn't work. >error C2513: '__time64_t' : no variable declared before '=' >time_t = t; Yep, this error is pretty straightforward too. You … | |
Re: Posting your homework isn't going to get you help. You need to specify what you don't understand, and if you want help with a solution, post what you've already tried so we don't assume you're mooching off of us. | |
Re: >what should i do for this? Read as much as you can, write as much code as you can, ask questions here, and try to answer them as well. Repeat ad infinitum. Pretty much everything you'd expect to acquire a difficult skill. | |
Re: >i was wondering if an xml could parse html You mean can an XML parser handle HTML? Probably not, given the differences between XML and HTML in terms of leniency and syntax. XHTML would be a better choice than HTML, I think. | |
Re: Put simply, it gives you a pointer to the starting address of text mode video memory. Since the address doesn't change, you can cast it to a pointer to char and assign to offsets from that pointer to write to the appropriate memory blocks. | |
Re: >Here is my constructor. Is that the whole of your constructor? If so, it's not accomplishing much of anything as you allocate memory to the local variable EmpPointer, and then proceed to leak memory when EmpPointer goes out of scope at the end of the constructor. | |
Re: >error C2106: '=' : left operand must be l-value In your code you say [ICODE]if ( n % i = 0 ){[/ICODE]. C++ uses == for equality and = for assignment, so you're using the wrong operator. >error C2065: 'i' : undeclared identifier This is a simple one: you haven't … | |
Re: >when i attempt to swap etc, it doesnt work and i get a crash Step through your code and see what the indices are just before you crash. By the look of things, you're trying to use a negative index, which suggests your math is off. Keep in mind that … | |
Re: >I need to create an array of strings using a set of string pointers. Why don't you describe what you're doing rather than how you want to do it. Perhaps there's a better way. | |
Re: >int *x; >fscanf(fin, "%i", x); Where does x point? | |
Re: >i am using miracle c compiler Miracle C is a [I][B]horrible[/B][/I] compiler. Trash it and get anything else, or you'll have to suffer through constant battles of perfectly valid code failing to compile or not working correctly. Try [URL="http://www.codeblocks.org/"]Code::Blocks[/URL], [URL="http://www.turboexplorer.com/cpp"]Turbo C++[/URL], or [URL="http://www.microsoft.com/express/vc/"]Visual C++[/URL]. | |
Re: [QUOTE=ajay.krish123;734153]abov e program can also be written as: [CODE] void main() { ------ ----- getch(); }[/CODE][/QUOTE] Yes, it can be...if you want your code to be subtly broken and non-portable. The main function returns int by definition. getch isn't a standard function, so you'd be relying on a library extension … | |
Re: Well, what's the type of page_directory[0]? page_directory is a pointer to unsigned long, right? So after an offset and dereference you'd be looking at an unsigned long, thus: [code=c] page_directory[0] = (unsigned long)page_table; [/code] That will make your error go away. | |
Re: >Is there a way to make a text based RPG game? No, it's impossible. :icon_rolleyes: | |
Re: >Please explain me briefly. I believe the customary response to such a lazy question is "Do your own damn homework!". | |
Re: >More strong (but not ideal) method is (an example only) Only an example because by the time you test for overflow, the damage is already done. Keep in mind that once you invoke undefined behavior, the rest of the program is undefined. You need to test before the damage is … | |
Re: That's not a portable operation, so we can't offer suggestions without at least knowing your operating system. Also knowing your compiler wouldn't hurt either. | |
Re: The vector class is in the std namespace. Change [ICODE]vector<FrequencyNode> list;[/ICODE] to [ICODE]std::vector<FrequencyNode> list;[/ICODE]. You have other errors though. | |
Re: int is a type built right into the language, which means you don't need to link with a library to use it. string (or std::string, to be specific) is a class in the standard library that gives you a string type. Ultimately the difference is minimal, aside from the fact … | |
Re: It's just a quirk of the text highlighting. I've found that when I'm mucking about with preprocessor directives, the highlighter can't always keep up with me and even though the code is correct, the highlighting is wrong. | |
Re: >im originally from the south of england so i should be smart Your accent probably makes you [I]sound[/I] smart. Don't be deceived! :icon_rolleyes:;) | |
Re: >but (as I've read) pointer arithmetic is faster Prove it. In your example, the two are quite likely compiled to exactly the same machine code. Array subscripting is literally syntactic sugar for the equivalent pointer offset calculation. A more likely example is this: [code=cplusplus] int x[N]; int *p = x; … | |
Re: >We need a programmer who is SMART in ASSEMBLY LANGUAGE Then why are you asking in a C forum? | |
Re: >Am I write[[I]sic[/I]] in thinking this? Makes sense to me. Though structures are best used for closely related data rather than just a variable dump. If the relationships aren't there, you may need to consider how you're structuring your program and redesign if necessary to streamline the flow. |
The End.