6,741 Posted Topics
Re: It's possible to draw, and read images, but you're limited basically to the ASCII art category of drawings. | |
Re: Why don't you profile them both and get more specific performance metrics? I'd guess (without looking closely at either program) that the difference is in caching. | |
Re: >// Here I want to delete the character, I'm not sure how to do that... Deleting a character essentially means overwriting it by shifting every character after it left by one cell: [code] abcdefg efg abcd efg abcd abcefg [/code] A loop to do this is relatively simple: [code=c] size_t … | |
Re: >I want to know if VC++ provides getter and setter >for each of these properties(like textbox,radiobutton) ? No, but it's trivial to write them yourself. You can also force generated controls to be public, but that's not a good practice. | |
Re: >save values to a file on program exit and read on program start Coupled with encryption and a good tampering check, I'd prefer this one. >save values in the registry Which adds a whole new layer of complexity to your application. Best to avoid the registry. >save values in the … | |
Re: >I could not answer the question why the compiler >was not saying anything to this construct. Compilers are only [I]required[/I] to notify you about constraint violations. Further errors, and warnings in particular, are specific to the compiler and are there only because they make a compiler more user-friendly and thus, … | |
Re: >dep(1,1,2000); >ret(1,1,2000); This is assuming that your Date class overloads the function call operator and allows three arguments. I'm guessing you don't have that particular overload, in which case what you were trying to do (initialize dep and ret to new instances of the Date class using a three parameter … | |
Re: There's nothing stopping your code from compiling as C++. If you really want to make it look more like C++, just replace scanf and printf with cin and cout. That's pretty much all you can do, as the program is extremely simple and doesn't use language specific features beyond I/O. | |
Re: >How do I access 'whatever'? You don't. That's the whole point of making it private. Only the class itself and friends of the class can access private members. You can allow access but still control it by offering a public interface: [code=cplusplus] class Foo { public: int blah; void set_whatever … | |
Here's a challenge for you C++ aces. The challenge is to write a function with the following declaration: [code] unsigned long extract_digits ( unsigned long x, size_t n, size_t i ); [/code] This challenge has three parts. [B]Part I (Beginner):[/B] Write the extract_digits function. It should return a sub-value of … | |
Re: >1. what syntax should i use to insert character that allows 'space'? cin.getline: [code=cplusplus] cin.getline ( emp->name, 50 ); [/code] >2. is there a syntax that can 'search' name within a list,,, what is it? It's called a loop: [code=cplusplus] node *it = strtPtr; while ( it != 0 ) … | |
Re: I see where you're trying to go with it, so I guess it does make sense. Why do you ask? | |
Re: >I need to figure out what i want to program, and then use the right language for the job. When you're first learning you need to just pick a language and go with it. You can't use the right language for the job if you don't have experience with the … | |
![]() | Re: First you need to decide if you want to use parameters to move s around, or access it globally. Right now you're mixing the two together and as a result you have way too many variables named s. This uses parameters rather than the global variable: [code=c] #include <stdio.h> void … |
Re: >it is like this ( int main ( int a , int b , char* c) ) Then it's wrong. The main function only supports these two definitions: [code=c] int main ( void ) { /* ... */ } [/code] [code=c] int main ( int argc, char *argv[] ) { … | |
Re: >if you find errors in the isFull and addMessage functions please let me know. I'll focus on those two, but be aware that there are problems in the rest of your code. >if(!isFull) You forgot that isFull is a function. It needs an argument list. >messages[numElements]+=message; >keys[numElements]+=key; Most likely you … | |
Re: >Now I would like to know about file handling. What exactly are you trying to do? >Also, could you let me know if there is any good material >(online) on the topic of LINKED LIST (Single & Double). I think [url=http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx]this[/url] is good, but I'm a little biased. >Do treat … | |
Re: >warning: the `gets' function is dangerous and should not be used. It's pretty self-explanatory, I think. gets is dangerous and shouldn't be used. So stop using it. :icon_rolleyes: May I suggest cin.getline as a replacement for gets? It's somewhat of a bad practice to mix the C style I/O functions … | |
Re: >Why is that ? It's easiest to understand if you have a perfect binary tree (all levels are full). Notice that each branch contains twice the number of nodes. This means that in a perfect binary tree, the number of nodes on each level is exactly the number of nodes … | |
Re: >share your ideas......what do you think....... I think you're not going to get anyone to tell you how to do this. It's your assignment after all. Start by figuring out how to read an expression from the input stream. You need to be able to build an integer from multiple … | |
Re: >Randomly generate a number within a certain ASCII >range then display the corresponding character. First, that's not a portable solution. Second, it's not an elegant solution either because you end up screwing around with multiple ranges and basically playing number games. A much better solution is to store all of … | |
Re: The compiler doesn't know where to look for total, so it looks for local variables and then global variables. If you want to access the static member, you have to qualify it with the class it's declared in: [code=cplusplus] item::total += a.itemprice; [/code] Alternatively you can use the object to … | |
Re: >i want to ask why we use an underscore here in ch=_getch(); Because that's how the compiler defines it, probably. | |
Re: All you need to do is keep a count of rows and a running sum of the values. You pretty much had it: [code=c] while (fgets(buf, 80, stocks) != NULL && !feof(stocks)) { sscanf(buf, "%d %d", &stock.x, &stock.y); printf("n1 = %d n2 = %d\n", stock.x, stock.y); total += stock.y; ++numberofrecords; … | |
Re: >Can u give me some advice to do it ? I can give you some advice, but you're not going to like it. My advice is to take a step back and work on simpler things, because you're trying to solve problems and write programs that are too far beyond … | |
Re: [code=c] int main() int next_state[8][2]= {0,4, [/code] The tag for main either doesn't belong there, or should be completed. As it is, you've got a syntax error because of a partial function declaration/definition. | |
Re: >#define pi 3.14159265; Lose the semicolon. The preprocessor is doing exactly what you tell it and replacing all occurrences of "pi" with "3.14159265;". | |
Re: A few tips: >printf("File Open Error %s", filename); >exit(0); Most likely you don't want to use stdout for your error messages. At the very least use stderr, and for more robust messaging, use your own stream. Either way you'll be using fprintf. Also, 0 means success, so [ICODE]exit(0)[/ICODE] is functionally … | |
Re: There's no portable way to do this. What compiler and operating system are you using? In anticipation of you being on Windows, you can use [URL="http://msdn2.microsoft.com/en-us/library/ms686047(VS.85).aspx"]SetConsoleTextAttribute [/URL]to give your text color. | |
Re: I can't say I know of any other than hiring an assembly programmer to tweak your assembly output. How is the compiler not sufficient for your needs? | |
Re: Random access is for when you can't predict the access pattern or you can't deterministically work out a pattern to organize your data for sequential access. Sequential access is for when you don't care about the order of records, can predict the access pattern or organize your data to fit … | |
Re: >what makes C a universal language C is old, ubiquitous, well understood, and many modern languages derive syntax and semantics from it. | |
Re: >while((i > 0) && (A[i] > key)); Remove the semicolon. What you have right now is a loop that either doesn't run at all, or runs forever. Here's the equivalent loop with braces: [code=c] while((i > 0) && (A[i] > key)) { ; } [/code] Also, your algorithm is incorrect, … | |
Re: >What are the following data types are and the storage requirements of each? This is something you can find in any C reference. So why are you even asking the question? char is a byte, the size is 1. unsigned char is a byte guaranteed never to have a negative … | |
Re: >Sorry to hear that. I'm not. We can easily do without people like that. | |
Re: Here's a hint, people. Use a fixed width font to set up spacing for your output. The post editor doesn't use a fixed width font, so open up Notepad or something equivalent and get your example looking right before you post it. Otherwise you'll end up with too many or … | |
Re: It looks like you've nailed down the problem, judging by the extra std::cin.get() calls, but putting them after a return statement means they won't get executed. For example, try swapping this pattern: [code=cplusplus] return 0; std::cin.get(); [/code] To get this one: [code=cplusplus] std::cin.get(); return 0; [/code] | |
Re: Perhaps you could help us a bit by explaining the error. | |
Re: Moved. FYI, "Assembly" in the Software Development->Assembly forum refers to assembly language for software programming, not hardware assembly. | |
Re: >found this is going to be a lot more work then originally expected What did you expect? I hear this a lot. "It wasn't what I expected!" I get the feeling that people have some pretty messed up expectations when it comes to learning something new. >and have become only … | |
Re: If you define a member function for a template class outside of the class definition, you need to recreate the template parameters: [code=cplusplus] template <typename T> myVector<T>::myVector() { size = 0; capacity = 10; data = new T [capacity]; } template <typename T> myVector<T>::~myVector() { delete [] data; } [/code] | |
Re: Your question makes very little sense. Please try explaining it again. | |
Re: What have you tried so far? What exactly don't you understand? Keep in mind that we're not going to just give you the code for your program without some effort on your part. | |
Re: >there's no such thing as a random number 100% accurate and 0% helpful. >but they're still not random. I don't think anybody here cares but you. If it looks random and acts random for your application, it's random. | |
Re: The filename parameter has to be a C-style string: [code=cplusplus] ifstream myfile1 (path1.c_str(), ios::binary); ofstream myfile3 (path2.c_str(), ios::binary); [/code] | |
Re: >So how can i made calculations on numbers out of Builting data types ranges. Use an arbitrary length math library such as [URL="http://gmplib.org/"]GMP[/URL], or write your own. | |
Re: Have you tried searching the forum? How about the web? It's not like this question isn't asked on a regular basis. | |
Re: >why is there no null character needed? Dumb luck. The next byte after your array just happens to have the value 0. >*(array + count) = ch ; Just out of curiosity, why add the unnecessary complexity of pointer notation here? | |
Re: You can specify one or more forums from the advanced forum search. Is that what you meant? |
The End.