6,741 Posted Topics
Re: >static int get_code ( void ) It's good to know that someone gets some use out of that function. :) ![]() | |
Re: >so how can i state a file size as "num_of_elements" There are basically two ways: 1) read the file and dynamically resize an array accordingly: [code] #include <stdio.h> #include <stdlib.h> int main ( void ) { FILE *in = fopen ( "test.txt", "r" ); if ( in != NULL ) … | |
Re: istream::get doesn't have an overload for std::string. You're probably thinking of getline: [code] getline ( cin, connect ); [/code] | |
Re: If cin fails to read the type it expects, it will enter an error state and won't accept further input. Try this: [code] while (n<1||n>10) { cout << "\nInvalid input. Try again (1..10) -> "; cin.clear(); cin >> n; cin.ignore(SHRT_MAX, '\n'); } [/code] Also, you need to initialize n to … | |
Re: LPCWSTR is a wide string type and a string literal is a narrow string type. The two aren't compatible. You can fix it in a number of ways. First, you can make the string wide by prefixing it with L, or you can use the _TEXT macro provided by the … | |
Re: Computer science is probably your best bet for a major that a lot of employers are familiar with and will help with further education. If your school has an undergraduate software engineering major then that will probably focus more on the implementation side rather than the theory of CS, but … | |
Re: And your question is? We're not going to give you code just because you're too lazy to do the work yourself. | |
Re: You search for the last delimiter (a space) and take whatever characters exist after it. This works because the deposit field is the last in the record line: [code] char *deposit = strrchr ( line, ' ' ); if ( deposit != NULL ) { ++deposit; /* Skip the delimiter … | |
Re: >How can i sort all the user in my text file base on their id The id is the first number on each line, so extracting it with sscanf is trivial. Do you know anything about sorting? Your question is extremely vague in terms of what you're capable of. I … | |
Re: First and foremost, you need to define an Mpg array. You're also reusing names too much, and that won't work. Your miles function does the operation, though it doesn't need either an mpg parameter or a local mpg. You can define it like this: [code] double get_mpg ( double miles, … | |
Re: I'm not sure what language it is you're speaking, but it reminds me of Gibberish. Your code has a lot of unnecessary junk in it that serves no real purpose. Tell me what your problem is with this: [code] #include <map> #include <string> #include <iostream> using namespace std; int main() … | |
Re: >There is also talk that one day, the older headers ending in ".h" may be completely removed from C++ You're confusing the C library headers, which *are* deprecated, with the non-standard C++ headers. The difference is that iostream.h and friends aren't required to be supported by an implementation in any … | |
Re: >Anyone have any ideas I have an idea: give it a try and see what you can come up with. >...newbie This won't encourage us to hand feed you any more than a direct request for a solution. | |
Re: Those are exceptionally detailed and clear diagnostic messages. What's the problem? 'array1' isn't used and 'array' isn't expected where you put it. Both fixes require no more than a remedial knowledge of C++. | |
Re: The first question is always why do you need to optimize it? | |
Re: >how do you get a RANDOM word from a text file? Unless the file is so large that placing it in memory is prohibitive, or you're under stupid restrictions, you read the text file into a suitable data structure that gives you convenient and efficient searching. | |
Re: >But I would like to say if a semi colon appears at any stage >after a ")" (closing bracket) add one to count. Where does a closing paren (brackets are '[' and ']') come into this? Are you not providing us with enough information to properly help you? | |
Re: >Is there a function that I can use that given a few vectors which elements are common to all? Look up set_intersection. >What if I have more than 2 vectors to compare Look up set_intersection with a focus on the return value and consider making multiple calls. | |
Re: Read the forum rules and adhere to them, or I'll continue to delete your threads. | |
Re: >a. what is pivot? A pivot is the one item that will be in sorted position after you partition the list. >b. give the resulting list after one call to the partition procedure. This depends on the partitioning algorithm. | |
Re: You need some way of reading raw input with a non-standard solution such as getch. Then it's just a matter of handling backspaces cleanly as printing an asterisk for every printing character that you read is trivial. | |
Re: >I dont know where I am going wrong as garbage is being stored in some of the char pointers. You're overcomplicating the problem. Compare and contrast your solution with this one: [code] #include <iostream> #include <iomanip> #include <cstring> using namespace std; void jsw_insertion ( char **a, int n ) { … | |
Re: >open the file, seek to end, the get current file position That's only guaranteed to be meaningful on files opened with a binary orientation. Even then there's a possibility that the size may be inaccurate. The only portable way to determine the working size of a file is to open … | |
Re: What operations do you have available? If you can only use push, pop, and empty then you're stuck with removing every item until the stack is empty and counting them. Any decent stack implementation will provide you with some form of size operation that will tell you how many items … | |
| |
Re: >These are some of the few questions for which i couldn't find answers. Clearly you didn't look very hard. Not only are these easy to figure out for just about anyone with some measure of experience, the answers are everywhere because people like you keep trying to get others to … | |
Re: The syntax problem is that you failed to terminate your forward declaration with a semicolon. But since you've already included <queue>, there's little point in a forward declaration anyway, and it'll cause you more problems. Remove this part and the code will compile: [code] template < class Type, class Container=vector<Type>, … | |
Re: >Compiler used by me is turbo c Turbo C is neither a C++ compiler, nor new enough to know what the C++ standard even is. Get something that isn't a complete dinosaur, like Dev-C++. There's no point in trying to learn C++ on a dead compiler; it'll just frustrate you. | |
Re: What does MSDN's reference on console programming say? | |
Re: No, there's not a function in either the C or C++ library that will do that. You do it manually. First by finding the end of the string and walking back as long as the current character is whitespace, then replace the last occurance of whitespace with '\0'. Then by … | |
Re: I would do it just like anyone else, and it would display just fine. Can you be more specific about what's not working? The shell doesn't interpret special characters when they're taken from a file, neither does C++. | |
Re: >i guess printf doest take a lot of processing :| printf doesn't do much internal processing, despite the length of the code for it. ;) The performance hits come from writing to an external device, which is extremely slow when compared to the simple internal data movement of a sort. | |
Re: Can you not use strstr to look for "hello my"? Or are you looking for any combination such as "my hello", hellomy", and so forth? In that case, the easiest way would be to use a regular expression, which C doesn't support as a standard library. You would need to … | |
Re: >I thought firewall will be too complex. If you do it right, yes. >And linux has noviruses so no Antivirus. Heheh, you've led a sheltered life. :) >What else can we do in network security? A lot. If you think that antivirus and firewalls are all there is to security … | |
Re: Well, you start by learning how to program. Maybe if you're a little more detailed in what your problem is, we can be more detailed in helping you. | |
Re: >are the argv[] strings in read-only memory? No, they're required to be writable. >I have traced it down to the "$" character on the command line. Can you paste your debug trace here? | |
Re: > Personally I would create the class (or perhaps an array of class objects) dynamically. That's a different thing entirely. Let's say you have an array class that grows and shrinks dynamically. How would creating the class dynamically solve that problem? It wouldn't; you would need to create and maintain … | |
Re: [url]http://www.daniweb.com/techtalkforums/thread39656.html[/url] | |
Re: >creates a dynamic array of 20 "Simulates" an array of 20. >if on run time the array needs to be 40 how could this be accomplished? Allocate a new block with the new size. Copy the contents of the old block. Free the memory of the old block. C++ doesn't … | |
Re: [QUOTE=bashi]thnks for your repy bench i will do the code part if u can help me plz do hlp me in this i cant understand how i will Show a complete class diagram against the system described above. i hope u will help me.[/QUOTE] I'm feeling generous today, so I'll … | |
Re: Getting the numeric value of a single character is simple: [code] char lang[2][4] = {"en","fr"}; int i = lang[0][0]; [/code] You're confused with the distinction between value and representation. The values of lang[0][0] and i are identical. The only difference is how they're printed, much like octal, decimal, and hexadecimal. … | |
Re: The only simple explanation I've found is [url=http://www.eternallyconfuzzled.com/articles/bigo.html]mine[/url]. | |
Re: >I want someone here to just read the charecters from the attachment to another file using c. Done. That was easy. Oh, did you want me to post it here? Tough luck, we won't do your homework for you. | |
Re: What have you tried? We're not going to write it for you. | |
Re: Are you linking with msvcrt.lib? Are you compiling with the /MT switch to specify a multi-threaded application? | |
Re: Your code has an error that makes the compiler panic. Go find it or post your code so that we can help you find it. | |
Re: >transform(myString.begin(),myString.end(),myString.begin(),toupper); Amazingly enough, that's correct, but I'm not sure if it's correct because you intended it to be or if it's correct because you messed up your headers. I don't recommend using toupper directly with transform because most programs will want to use the toupper declared in <cctype>, but will … | |
Re: You're trying to assign a string (char *) to a variable that isn't a pointer. | |
Re: You rarely want to return the address of a local variable, and then the only way for it to work is to declare it as static. Why? Because local variables are created when the function begins and destroyed when the function ends. The memory you're referencing no longer belongs to … |
The End.