159 Posted Topics

Member Avatar for j-green.10

You should delete the line because it makes no sense? What are you trying to do anyway?

Member Avatar for j-green.10
0
73
Member Avatar for CroBoss

cout and endl are in the namespace std. so you either need to prepend std:: when you refer to them or add using namespace std;.

Member Avatar for CroBoss
0
231
Member Avatar for blaisemcrowly

Declare main as follows: [code]int main(int argc,char** argv) { ... }[/code] argc is the number of arguments, argv is an array with the arguments. The first argument is always the command line that was used to execute the program (without parameters), the rest are the actual parameters.

Member Avatar for Aranarth
0
102
Member Avatar for programer alex
Member Avatar for Aranarth
-7
40
Member Avatar for arpal

See [url]http://www.cplusplus.com/reference/clibrary/csignal/signal/[/url] Note that in the case of a segmentation fault or division by zero all you can do in the signal handlers is to terminate the program in a controlled way, because when the signal handler exits, execution will be continued at the point where the problem occurred, which …

Member Avatar for Aranarth
0
121
Member Avatar for doc15

Some comments that could help you with this and future projects: 1. It's better to declare variables as soon as they are needed (and not at the beginning of the function). That way, you don't have to scroll up to check what type the variable is and you don't have …

Member Avatar for doc15
0
1K
Member Avatar for VorSec

It's not necessary to create your own split function, as boost has one and even foreach if you want. [code]#include <iostream> #include <string> #include <vector> #include <boost/algorithm/string.hpp> #include <boost/foreach.hpp> using namespace std; using namespace boost; #define foreach BOOST_FOREACH int main() { string s = "@This@Is@My@String@"; vector<string> parts; split(parts,s,is_any_of("@")); foreach(string& p,parts)cout …

Member Avatar for iamthwee
0
1K
Member Avatar for ghost_from_sa

I'm not surprised you didn't get any help, since you never explained what the problem is.

Member Avatar for ghost_from_sa
-1
133
Member Avatar for dansnyderECE

It would really help if you could post the entire input file, that would allow us to debug the code and quickly find the remaining issues. Of course, it would save yourself a lot of time in the future if you just learn on how to use the debugger yourself. …

Member Avatar for dansnyderECE
0
384
Member Avatar for catdieselpow

This thread is nearly three years old, just saying. [QUOTE]int i,k=0,j; int a[3]; int b[3]; int c[6]; bool flag; //cout<< [/QUOTE] Uh? Sometimes I just don't get what people are thinking...

Member Avatar for Aranarth
0
100
Member Avatar for moqbel

[QUOTE=Nick Evan;1241871]First of all: Why? This sounds like you're making somesort of malware/spyware and that's against the rules.[/QUOTE] There would be no point for malware to do something like that..

Member Avatar for Nick Evan
0
105
Member Avatar for Beeko

You will need OS-specific functions to do that. I assume you're using Windows. For the cursor, there is GetCursorPos and SetCursorPos. If you want to simulate mouse clicks, you can use functions like SendInput or PostMessage. In any case, you'll spend much time studying on MSDN.

Member Avatar for Beeko
0
186
Member Avatar for albertkao

-O3 goes without saying if you need to program to be fast. How a function object is supposed to speed up anything is beyond me, though.

Member Avatar for Rajesh R Subram
0
110
Member Avatar for eng hassan
Member Avatar for dansnyderECE

My guess is that there are words in the file that are longer than the 7 chars that fit in Hex. Never use char arrays unless you know exactly what you're doing - use string instead. By the way, the code inside the for( int y=7;y>=0;y--) loop is unnecessarily redundant. …

Member Avatar for dansnyderECE
0
184
Member Avatar for God Coder123

[code]const int arraySize=sizeof(Array)/sizeof(*Array); cout << Array[rand()%arraySize] << endl;[/code]

Member Avatar for God Coder123
0
108
Member Avatar for Thew

That's most likely because the other computer has a different locale. For example, the same date might have to be specified as 01.01.2010 on that system.

Member Avatar for Aranarth
0
246
Member Avatar for ryan858
Member Avatar for Aranarth
0
86
Member Avatar for Excizted

I wrote this code many years ago and due to the less than stellar variable names it's hard to understand - but well, it works. [code]static bool PlaceHolderMatch(const char* QS,const char* MS,int QL,int ML,char Placeholder='?') { if (QL!=ML)return false; for (int i=0;i<QL;i++) { if (MS[i]==Placeholder)continue; if (MS[i]!=QS[i])return false; } return …

Member Avatar for NathanOliver
0
5K
Member Avatar for aay

Whenever you find a space, delete all spaces that come right after it. Deleting a character is done by moving all following characters one position down.

Member Avatar for aay
0
684
Member Avatar for eng hassan
Member Avatar for Brandon515

The first problem is that you use char* instead of string. The second is that you're using getline wrong: [code]getline(file,black.day);[/code]

Member Avatar for jonsca
0
148
Member Avatar for shayankhan

There is no sense in storing all names in the same char array. What you're looking for is an array of strings. [code]string names[7]; for (int i=0;i<7;i++) { cin >> names[i]; }[/code]

Member Avatar for shayankhan
0
95
Member Avatar for Leppie

Aside from an intToStr function, you should also create yourself a leadingZeros function, which you'll probably want to use here. You'll need both very often, so it's a good idea to create a small library with such functions for private use. You can also use boost's lexical_cast instead of intToStr.

Member Avatar for Leppie
0
2K
Member Avatar for abhi74k

Temporary objects aren't [i]strictly[/i] const. While they act const when trying to pass them to a function, you can still call non-const functions on them. Consider this: [code]class A { public: A() : num(0) {} void setToFive() {num=5;} int num; }; void setAToFive(A& a) { a.num=5; } int main() { …

Member Avatar for Aranarth
0
150
Member Avatar for new2programming

Look up srand and rand to generate random numbers. If you have ten different item types, generate a number between 0 and 9 and create the item matching that number.

Member Avatar for Aranarth
0
95
Member Avatar for Excizted

I see two problems: 1. You're using delete (instead of delete[]) on buf, even though the array was created with new[]. 2. In FileSystemDataStream::open you're returning an object created with new as a regular pointer (instead of auto_ptr) which opens the gates to the realm of potential double deletes and …

Member Avatar for Excizted
0
3K
Member Avatar for Babatuda

Either the program is already running or you simply don't have write access to that directory.

Member Avatar for avarionist
0
452
Member Avatar for leesho

You seriously need to indent your code, then mistakes with extra or missing braces couldn't happen.

Member Avatar for leesho
0
184
Member Avatar for Talguy

I don't explicitly write this-> unless necessary. There is no point - it's a [i]considerable[/i] extra effort since most of the function code you write is inside one class or another. And there is no real benefit - the only reason you would need to write this-> is because you …

Member Avatar for Aranarth
0
116
Member Avatar for robski

"Define a new data type" means you're supposed to create a new class (or possibly three).

Member Avatar for robski
0
115
Member Avatar for iamthwee

And here's another. This will be many, many times faster if the file contains a lot of entries. [code]#include <iostream> #include <fstream> #include <string> #include <vector> #include <map> #include <sstream> using namespace std; struct Foo { Foo() : quantity(0) {} Foo(const string& part,const string& a,const string& b,int quantity) : part(part), …

Member Avatar for iamthwee
0
281
Member Avatar for gcardonav

Use the debugger, it'll take just a minute to find the problem. Compile with g++ -g -o test test.cpp to include debug information, then run gdb test And enter the commands start, then continue. When it stops due to the segmentation fault, type "where".

Member Avatar for gcardonav
0
139
Member Avatar for igorg95

C&P from the other forum: [QUOTE]Yes, you can do this with MinGW. This was compiled using MinGW on Linux: [url]http://94.23.22.190/etc/voc.exe[/url] MinGW exists for the Mac too: [url]http://crossgcc.rts-software.org/doku.php[/url][/QUOTE]

Member Avatar for igorg95
0
134
Member Avatar for sblass92

Function pointers are the way to go: [CODE]class button { public: button(void (*onClick)(button&)) : onClick(onClick) {} void click() {onClick(*this);} private: void (*onClick)(button&); }; void myOnClick(button& owner) { cout << "Button clicked!" << endl; } int main() { button myButton(myOnClick); myButton.click(); }[/CODE] If you don't want to use function pointers, you …

Member Avatar for Aranarth
0
160
Member Avatar for Ral78

I'd also like to point out that it's very bad style to declare counter variables outside the for loop, unless you actually need the value the loop stopped at.

Member Avatar for Ral78
0
150
Member Avatar for Sandhya212

[QUOTE]then I need to pair every element of the 2nd column like this. C++ Syntax (Toggle Plain Text) 1. {(1,3),(1,5),(1,8),(1,9),(1,7),(1,10),(2,3).....} {(1,3),(1,5),(1,8),(1,9),(1,7),(1,10),(2,3).....} ie pairs are formed between elements only if their elements in the 1st row are different. [/QUOTE] Maybe you should explain this again. For example, why is (1,2) not …

Member Avatar for Sandhya212
0
245
Member Avatar for GamerXxX

Why are you calling rand() twice on each line? That makes no sense. Besides, the code has nothing to do with your problem. And you might want to formulate an actual question, because I'm not sure what your problem exactly is.

Member Avatar for GamerXxX
0
762
Member Avatar for ifezuec

[CODE]struct matrix_2x2 { //interesting functions here double v[2][2]; };[/CODE]?

Member Avatar for NP-complete
0
72
Member Avatar for Bukhari1986

You should look up the string class method substr, it does what you need. [CODE]string str="0092-123-1234567"; int cpos=0; while (cpos<str.length() && str[cpos]!='-')cpos++; if (cpos>=str.length())error(); //no '-' found string tail=str.substr(cpos+1,str.length()-cpos-1);[/CODE]

Member Avatar for Bukhari1986
-2
137
Member Avatar for programing

string is included by iostream, so you can just omit the include and still use strings.

Member Avatar for NP-complete
0
150
Member Avatar for didi00
Member Avatar for didi00
0
353
Member Avatar for daniel88

In this case, using getline is appropriate: [CODE]ItemizedProductLine::ItemizedProductLine(ProductCode pc, double rrp, double sp, int oh, char* desc): ProductLine(pc, rrp, sp, oh, desc) { for (;;) { cout << "Please enter serial number:" << endl; string serial; getline(cin,serial); if (serial.empty())break; serialNumbers.insert(serial); } }[/CODE]

Member Avatar for daniel88
0
106
Member Avatar for blackmagic01021

Just check if all values in the resulting long array are within the value range of short. If so, you can transfer the data over to a short array.

Member Avatar for Aranarth
0
78
Member Avatar for darelet

A glaring mistake I noticed when skimming the code is [code]float *real=new float[width*height]; real=convolve2D(data,gx_r,gy,filterHalfWidth); float *imaginary=new float[width*height]; imaginary=convolve2D(data,gx_i,gy,filterHalfWidth); [/code] You're requesting memory for real and imaginary, then immediately overwrite the pointer, creating a huge memory leak. And while I see an abundance of new[]s in other parts of your code, …

Member Avatar for darelet
0
155
Member Avatar for jwelsh

This would defeat the purpose of libraries. When moving all code into header files, it would be included in all programs that use it, instead of separate .dll or .so files. When bugs are fixed in a library, you couldn't just replace the shared library - you would have to …

Member Avatar for corby
0
617
Member Avatar for rohan1020

To get the title of a window, you can use GetWindowText. You will need to acquire the target window's handle first.

Member Avatar for Aranarth
0
105
Member Avatar for paycity
Member Avatar for paycity
0
480
Member Avatar for Zcool31

First off, using delete on a null pointer never throws and is perfectly okay. A SIGTRAP can indicate memory corruption or a double free. Remember that the memory corruption does not necessarily need to occur in Flob.cpp. You also should consequently use new and delete/delete[] in your programs to avoid …

Member Avatar for Zcool31
0
3K
Member Avatar for fellixombc

Problems I'm seeing: 1. I don't see size being initialized anywhere, so even the first call to Recv could crash the program due to trying to allocate ridiculous amounts of memory. 2. You are not checking the return value of recv to see whether the connection has been terminated. Perhaps …

Member Avatar for fellixombc
0
139

The End.