6,741 Posted Topics

Member Avatar for tyczj

>static int get_code ( void ) It's good to know that someone gets some use out of that function. :)

Member Avatar for iamthwee
0
1K
Member Avatar for crws416

>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 ) …

Member Avatar for crws416
0
163
Member Avatar for Coach_Nate

istream::get doesn't have an overload for std::string. You're probably thinking of getline: [code] getline ( cin, connect ); [/code]

Member Avatar for Narue
0
137
Member Avatar for MrBrilliant

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 …

Member Avatar for MrBrilliant
0
246
Member Avatar for JoBe

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 …

Member Avatar for WolfPack
0
670
Member Avatar for Virii

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 …

Member Avatar for Narue
0
279
Member Avatar for narsimha.ram

And your question is? We're not going to give you code just because you're too lazy to do the work yourself.

Member Avatar for Salem
0
106
Member Avatar for squall8985

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 …

Member Avatar for Narue
0
256
Member Avatar for squall8985

>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 …

Member Avatar for squall8985
0
215
Member Avatar for rgrwalker

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, …

Member Avatar for Narue
0
85
Member Avatar for Whodey

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() …

Member Avatar for Narue
0
99
Member Avatar for Kiba Ookami

>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 …

Member Avatar for Narue
0
115
Member Avatar for egor

>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.

Member Avatar for dwks
0
106
Member Avatar for candykane69

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++.

Member Avatar for candykane69
0
99
Member Avatar for rasheed1982
Member Avatar for Ancient Dragon
0
138
Member Avatar for kryptolite

>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.

Member Avatar for AhmedHan
0
203
Member Avatar for Jon182

>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?

Member Avatar for Jon182
0
130
Member Avatar for winbatch

>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.

Member Avatar for Narue
0
126
Member Avatar for brianotieno

Read the forum rules and adhere to them, or I'll continue to delete your threads.

Member Avatar for Rashakil Fol
0
104
Member Avatar for btech

>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.

Member Avatar for Narue
0
111
Member Avatar for harrypotter

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.

Member Avatar for agiorgio
0
126
Member Avatar for comwizz

>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 ) { …

Member Avatar for HackWizz
0
355
Member Avatar for khot_anuradha

>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 …

Member Avatar for agiorgio
0
368
Member Avatar for thehakan

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 …

Member Avatar for thehakan
0
184
Member Avatar for 111Help
Member Avatar for Lerner
0
124
Member Avatar for stackOverflow

>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 …

Member Avatar for Bench
-1
319
Member Avatar for kharri5

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>, …

Member Avatar for kharri5
0
389
Member Avatar for HackWizz

>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.

Member Avatar for HackWizz
0
211
Member Avatar for sixtysecasasin
Member Avatar for Jon182

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 …

Member Avatar for Narue
0
158
Member Avatar for sixtysecasasin

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++.

Member Avatar for Bench
0
178
Member Avatar for ultra vires

>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.

Member Avatar for bumsfeld
0
153
Member Avatar for Jon182

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 …

Member Avatar for Bench
0
241
Member Avatar for cppbeginner
Member Avatar for akshayabc

>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 …

Member Avatar for Narue
0
919
Member Avatar for harrypotter

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.

Member Avatar for Narue
0
75
Member Avatar for crusty_collins

>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?

Member Avatar for crusty_collins
0
341
Member Avatar for shortLived

> 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 …

Member Avatar for shortLived
0
176
Member Avatar for server_crash
Member Avatar for Acidburn

>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 …

Member Avatar for Narue
0
111
Member Avatar for bashi

[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 …

Member Avatar for Bench
-1
261
Member Avatar for perlsu

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. …

Member Avatar for Narue
0
832
Member Avatar for webmasts

The only simple explanation I've found is [url=http://www.eternallyconfuzzled.com/articles/bigo.html]mine[/url].

Member Avatar for Narue
0
66
Member Avatar for sark4_rahul

>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.

Member Avatar for Narue
0
88
Member Avatar for ahkeah
Member Avatar for perlsu

Are you linking with msvcrt.lib? Are you compiling with the /MT switch to specify a multi-threaded application?

Member Avatar for Narue
0
55
Member Avatar for perlsu

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.

Member Avatar for SpS
0
198
Member Avatar for muthuivs

>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 …

Member Avatar for beuls
0
253
Member Avatar for Acidburn

You're trying to assign a string (char *) to a variable that isn't a pointer.

Member Avatar for Narue
0
77
Member Avatar for Acidburn

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 …

Member Avatar for Narue
0
275

The End.