353 Posted Topics

Member Avatar for Black Magic

> the moniter doesn't communicate with the PC in any way Unless it's a touch screen. Ed has worked with those before, and it's treated just like a mouse in the code.

Member Avatar for Duoas
0
121
Member Avatar for savinki

> why cant we use strcat without initialing first parameter? Because the first parameter is the array that strcat writes to. It can't be an uninitialized pointer because you have to own the memory that the pointer points to and it can't be a pointer to a string literal because …

Member Avatar for Radical Edward
0
82
Member Avatar for sieghart0123

The 1st approach will be easier and probably faster as well, but it will use more memory at any given time. Using more memory means the chance of thrashing is increased, and the performance will drop a lot. The 2nd approach will be trickier to implement and maintain, and will …

Member Avatar for Radical Edward
0
80
Member Avatar for Jennifer84

> Form2_Load is an event that executes code when a Form opens the first time ? That's right. > is it possible to call this Event anyway when the form already is open within a buttoncontrol like this Sure, an event handler is just another method. It's confusing though. A …

Member Avatar for Radical Edward
0
141
Member Avatar for joshmo

> how can i check if my text file is empty??? Try to read from it. If the read fails with eofbit set, the file is empty: [code] bool IsEmpty(std::istream& is) { char ch; is.get(ch); return is.eof(); } [/code] Remember that eof() only returns true [B]after [/B]a failed input request.

Member Avatar for Radical Edward
0
107
Member Avatar for timdog345

Initializing numb is easy. Just start at 1 and double the last value until you get to the size of the array: [code] int k = 1; for (int i = 0; i < 10; ++i) { numb[i] = k; k *= 2; } [/code] Initializing numb2 is a lot …

Member Avatar for timdog345
0
84
Member Avatar for Gagless

> bool String1EqualString2( char ArrayA[], int SizeA, char ArrayB[], int SizeB ) There's no need to pass the size of each string. C strings are always terminated by the '\0' character or they aren't legal strings. You can use that character as the base case for recursion. Since you can't …

Member Avatar for William Hemsworth
0
1K
Member Avatar for lifesuk

Check the first non-whitespace character. If it starts a comment, continue the loop: [code] inFile.open("data.txt"); while (inFile >> product) { if (product[0] == '#') continue; cout << product << '\n'; } [/code] Ed's code assumes that there won't be any leading whitespace. The code also shows you how to cleanly …

Member Avatar for Nick Evan
0
3K
Member Avatar for savinki

Probably easiest would be to read the length and then extract the characters after it one by one. The code is longer because Ed put in complete error checking: [code] #include <cctype> #include <cstdlib> #include <iostream> int main() { char *p = "6gterfs2rt5tyuri4oiuy10rtyuioiuyt"; char *data = p; long length; while …

Member Avatar for Radical Edward
0
169
Member Avatar for jpd727

That happens when you run the program from an IDE that doesn't keep the window open or if you run the program by double clicking on an icon. It happens because the lifetime of the window is controlled by the lifetime of the program. When execution returns from main, the …

Member Avatar for Radical Edward
0
109
Member Avatar for nelledawg

> Which would be more acceptable to use? It depends on a few things. The most obvious is that neither getch() nor system("pause") work everywhere. getch(): [LIST=1] [*]Isn't mandated by the C standard, so you can't assume it's available. [/LIST] system("pause"): [LIST=1] [*]Requires that an external program called pause exists. …

Member Avatar for Radical Edward
0
161
Member Avatar for savinki

> Here is the c++ way of doing that Two things: [LIST=1] [*]Your code isn't quite right. It ignores the last set of strings. [*]If you're going to do it the C++ way, let the class do all of the work: [/LIST] [code] #include <iostream> #include <sstream> #include <string> #include …

Member Avatar for Radical Edward
0
277
Member Avatar for arleyquininy

Edward is having the same problem. The avatar is not animated and meets the size restrictions. I thought it was because Ed didn't have enough posts, but I'm not sure anymore.

Member Avatar for Radical Edward
0
158
Member Avatar for Jennifer84

You probably need to refresh the form. Invalidate the label after changing the text so that it redraws: [code] labelText1->Text = ""; labelText2->Text = "TextMessage2"; labelText1->Invalidate(); labelText2->Invalidate(); [/code]

Member Avatar for Jennifer84
0
133
Member Avatar for savinki

Ed should emphasize that Ancient Dragon was talking about the binary value of a long int, not the character representation. A lot of times when people want to "cast" a string to another type they really mean a string conversion rather than a real cast: [code] #include <exception> #include <iostream> …

Member Avatar for Radical Edward
0
231
Member Avatar for daviddoria

Ed would do this by defining a "window" into the file so that only a small part of the file is in memory at any given moment to save memory. When accessing a record that isn't in the window, the window is moved appropriately. How you move the window depends …

Member Avatar for Radical Edward
0
95
Member Avatar for calichik

So you need help with all of the hard parts? ;) It'll be easier to help you if you ask something more specific, like if you try to do some of the code but have an error.

Member Avatar for calichik
0
102
Member Avatar for Cybulski

>What should constructor do, if something goes wrong, and further construction of object have no sense? Log the error if necessary and throw an exception. Then the code that's trying to create the object can decide what to do.

Member Avatar for Cybulski
0
98
Member Avatar for QuantNeeds

> the data type is integer but it is not catching decimal numbers Can you give an example run of the program and point out where the actual results don't coincide with your expected results?

Member Avatar for n1337
0
81
Member Avatar for peachslasher

> I am unsure where to insert my counter in my function to counts the comparison properly? Anywhere you compare the data that's being sorted, increment the counter. Here's one way Edward would do it: [code] #include <algorithm> #include <cstdlib> #include <ctime> #include <iostream> #include <iterator> #include <vector> template <typename …

Member Avatar for Radical Edward
0
281
Member Avatar for sash007

Edward doesn't like just bumping people off to another website, but perhaps [url=http://www.mcs.csuhayward.edu/~malek/Mathlinks/Weekdays.html]this[/url] is what you're looking for?

Member Avatar for sash007
0
134
Member Avatar for uk101man

The hardest part is opening the file, then it's just like reading input from cin: [code] #include <fstream> #include <iostream> #include <string> int main() { std::ifstream is("myfile"); std::string line; while (std::getline(is, line)) { std::string::size_type start = line.find("AT+COPS"); if (start != std::string::npos) std::cout << line.substr(start) << '\n'; } } [/code]

Member Avatar for Ancient Dragon
0
102
Member Avatar for Jennifer84

List<> is a managed type from the .NET framework. To declare the type you need to make it a managed reference and to instantiate the object you need to use gcnew instead of new: [code] using namespace System; using namespace System::Collections::Generic; int main() { List<String^>^ OneVector = gcnew List<String^>(); for …

Member Avatar for Radical Edward
0
186
Member Avatar for riahc3

> If Im not clear on something, go ahead and ask. What is it you want? Edward prefers to see the best in others, but if you only post the requirements of your program, at least one person is going to think you want it all written for you. It's …

Member Avatar for Clockowl
0
181
Member Avatar for Black Magic

Potentially quicker, you can use the STL min and max template functions. It's definitely easier, but it gets tedious with more than a few numbers: [code] #include <iostream> #include <algorithm> int main() { int a = 0; int b = 1; int c = 2; std::cout << "Low number: " …

Member Avatar for n.aggel
0
151
Member Avatar for toolbox03

> but you'd have to write a function to convert an entire string. A lot of compilers also have this kind of function as an extension to the standard library: [code] #include <stdio.h> #include <string.h> int main() { char line[1024]; if (fgets(line, sizeof line, stdin) != NULL) { fputs(line, stdout); …

Member Avatar for jephthah
0
232
Member Avatar for chazzquire

Edward isn't an expert on getch, but isn't the very definition of getch to read unbuffered input directly from the keyboard? Please post your code so that Ed can get a better idea of what you're trying to do.

Member Avatar for chazzquire
0
159
Member Avatar for picass0

The documentation is all you really need, but an example always helps. :) [code] #include <iostream> #include <string> #include <vector> int main() { typedef std::vector<std::string::size_type> IndexList; std::string s = "hello baby"; IndexList indexes; std::string::size_type index = 0; while ((index = s.find('l', index)) != std::string::npos) { indexes.push_back(index); ++index; } for (IndexList::const_iterator …

Member Avatar for Radical Edward
0
78
Member Avatar for picass0

Here's how Ed would do it: [code] #include <iostream> #include <string> int main() { std::string line; std::getline(std::cin, line); for (int i = 0; i < line.length(); i++) { std::cout << line[i]; if ((i + 1) % 4 == 0) std::cout << '\n'; } } [/code] If the value of the …

Member Avatar for Radical Edward
0
92
Member Avatar for shadowfire36

It's just as the error says. The variable you pass to SearchMatches is an array of Match pointers, not an array of Match objects: [code] //initailze the matches ( array of strcuts ) Match *matches[2000]; [/code] There's no conversion from [ICODE]Match *matches[2000][/ICODE] to [ICODE]Match *matches[/ICODE]. The only way to fix …

Member Avatar for shadowfire36
0
140
Member Avatar for TheFueley

Header files are usually included more than once, but you can only have one class definition. There are ways to make sure that a header isn't included more than once even if the programmer tries, and Edward's recommendation is header guards: [code] #ifndef NAME_H #define NAME_H //Name.h #include <string> using …

Member Avatar for TheFueley
0
178
Member Avatar for Najid

> input three numbers and display largest one Break it down into testing two numbers. Find the largest of the first two, then find the largest of that test and the third. Edward won't do your homework for you, but an example always helps. Here is some code that probably …

Member Avatar for Radical Edward
0
106
Member Avatar for Jennifer84

> So I am trying to identify if the line contain any "Real Charaters"/typed characters from the keyboard. Your idea of "Real Characters" and C++'s idea are probably different. If one of the cctype functions searches for what you want, you can use that along with the STL: [code] #include …

Member Avatar for Radical Edward
0
91
Member Avatar for ze-m!nd
Member Avatar for henpecked1

> what kind/type of binary operators can I use if I want the left operand to be a primitive type and the right operand to be a class? Any binary operator that you can overload will support this, but you have to make sure that it's a non-member function so …

Member Avatar for Radical Edward
0
117
Member Avatar for shahidrasul

It's easy! All you have to do is create an ifstream object and then use it just like you use cin: [code] #include <fstream> #include <iostream> int main() { ifstream is("filename"); int input; if (is >> input) std::cout << "Read " << input << '\n'; else std::cout << "Couldn't read …

Member Avatar for Radical Edward
0
97
Member Avatar for ulrik04

cin is expecting a different type than the next word has. You need to clear the stream state first because if it fails you won't be able to read anything else, then you need to remove the bad characters and try again. Removing the bad characters can be tricky, but …

Member Avatar for Radical Edward
0
110
Member Avatar for twgood

> 2. What will be printed if the input is 100? Your grade is X you did great This answer is not correct. Be sure to carefully check what the boundary number is for each case. > 4. What will be printed if the user enters “Wingding”? how did you …

Member Avatar for jephthah
0
204
Member Avatar for emilio

The same number or some numbers are being repeated? Your code works just fine when Edward tests it, but repeated numbers are expected unless you go out of your way to avoid them with something like a random shuffle: [code] #include <stdio.h> #include <stdlib.h> #include <time.h> static int *values; static …

Member Avatar for emilio
0
118
Member Avatar for Traicey

Edward can't speak for anyone else, but Ed uses header files to localize the declaration of a class and hiding of the definition. If you have a header, you don't have to repeat the class declaration for every single file you want to use the class in, and you also …

Member Avatar for Traicey
0
129
Member Avatar for CE Student

What errors are you getting? The code compiles for Edward with only a warning about IDs being used before initialization.

Member Avatar for Radical Edward
0
178
Member Avatar for BigFormat

>I don't know where to allocate buffer... Since you're passing the buffer by reference to string_concat, you should allocate the buffer in main, but if string_concat tries to make the string longer than the buffer can hold, you still have a reference to the original pointer and can use realloc. …

Member Avatar for BigFormat
0
2K
Member Avatar for knowledgelover

Edward handles the interaction of services and external programs by using XML files. The external program writes an XML file with all of the information the service needs, and the service reads the XML file to retrieve the information.

Member Avatar for knowledgelover
0
108
Member Avatar for knowledgelover

> I need my c++ (native code ) to perform some actions that I already have a c# code that perform it You do it the same way you call managed code from VB6: Make sure the C# code has a COM callable wrapper and use COM from native C++ …

Member Avatar for mitrmkar
0
394
Member Avatar for Traicey

> What is so difficult to understand about this: Is that a trick question? Of course it's difficult to understand if you haven't learned how it works yet. :-O Edward learned long ago that just because something is easy for her, it's not easy for everyone else, and vice versa.

Member Avatar for DigitalPackrat
0
404
Member Avatar for Jennifer84

> I am not sure if I understand. Ed was afraid that might happen. Duoas isn't describing Windows Forms, so his suggestions won't work for you. The code you want is [ICODE]Form2::VerticalScroll->Value = 0;[/ICODE], but if Ed remembers correctly, that won't work as well as you probably want with the …

Member Avatar for Jennifer84
0
181
Member Avatar for En1ro
Member Avatar for sakky12

What do you mean by module? C# basically has classes, files, assemblies, and namespaces. All of those work together to help you organize your code. Organizing code depends on your preferences and any coding guidelines you follow, so there's no "right" way of doing it. > I dont understand the …

Member Avatar for Radical Edward
0
68
Member Avatar for manzoor

> using relational operators and if statement only not else statement without > checking each number in if statement against each other You've put in too many restrictions. You have to test each number against the other at some point to find the maximum. Using only relational operators and if …

Member Avatar for William Hemsworth
0
104
Member Avatar for toolbox03

Ed would start with something like this: [code] fin >> records; for (int i = 0; i < records; ++i) { // Load the customer data fin >> name >> id >> status >> nproducts; c[i].SetInfo(name, id, status, nproducts); // Load the product data for this customer for (int j …

Member Avatar for VernonDozier
0
108

The End.