Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

fputs() is the opposite of fgets(), which is not what you want. You want to call strcpy() or strcpy_s() to duplicate a string.

lines 18 and 24 of server.c are wrong too. Remove the & symbol because its already a pointer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Every once in awhile I get email from my web site vBulletin that there is an error on MySQL. Below is the most recent error message. Looks like it might be caused by a hacker to me, what do you think? I've asked the technicians at iPage and they have no clue.

Database error in vBulletin 4.1.12:

Invalid SQL:

            SELECT text, languageid, special
            FROM phrase AS phrase
            LEFT JOIN phrasetype USING (fieldname)
            WHERE phrase.fieldname = 'error'
                AND varname = 'humanverify_image_wronganswer' AND languageid IN (-1, 0, 1);

MySQL Error   : MySQL server has gone away
Error Number  : 2006
Request Date  : Thursday, May 10th 2012 @ 03:11:52 AM
Error Date    : Thursday, May 10th 2012 @ 03:11:54 AM
Script        : <snipped>
Referrer      : <snipped>
IP Address    : 192.162.19.183
Username      : Steeseebups
Classname     : vB_Database
MySQL Version :
d

Another error message

Database error in vBulletin :

mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Can't connect to MySQL server on 'stoberwebcom.ipagemysql.com' (4)
/hermes/bosweb/web243/b2436/ipg.stoberwebcom/forums/includes/class_core.php on line 317

MySQL Error   : 
Error Number  : 
Request Date  : Saturday, May 5th 2012 @ 12:41:27 PM
Error Date    : Saturday, May 5th 2012 @ 12:44:13 PM
Script        : <snipped>
Referrer      : 
IP Address    : 66.249.72.194
Username      : 
Classname     : vB_Database
MySQL Version : 
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sounds like you need a course in c++, not Eclipse. Eclipse is just an IDE -- a programmer's tool, much like a hammer is to a carpenter. You don't learn how to build a house by asking how to use a hammer.

DeanMSands3 commented: Well said, sir. Well said. +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I also have no idea why the data type "string" is not existent in C++ windows forms applications.

Windows Forms is not c++, its CLI/C++ which is a slightly different language. CLI/C++ does not support c++ code or classes like std::string, std::vector, etc. The VC++ 2010 compiler has some of the classes in the include/cliext and is in cliext namespace, not std namespace. If you are not familiar with cli/c++ then you should read one of the many tutorials and walkthroughs that you can easily find with google. Yes I know its difficult to figure out where everything is because you can' just include <string> header file and expect to use its String class.

As for your specific problem, I don't know either because I have not used CLI/C++ enough, but I'm sure that is a common problem and your should be able to google for the answer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

For *nix read some of these threads

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It all depends on the operating system, and sometimes on the compiler you are using. For MS-Windows use console win32 api functions Note that you can't use the old MS-DOS color codes with modern MS-Windows compilers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The code you wrote is not reading the file.
Instead of MyReadFile.eof() do this, assuming MyReadFile is std::ifstream

std::string line;
while( getline(line, MyReadFile) )
{
   // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I dont know semaphores and threads

Then start learning. Read up on them then write a small program that illustrates how they work.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are rich enough to buy one of those new electric cars, you most likely won't mind paying 8 to 10 bucks for gas/petrol.

Whata bet? I have a 2011 Toyota Prius that gets 48-52 mpg, but I still bitch about petro prices.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

@adityawkhare: You can't generate a message box like you might see on other MS-Windows programs because Turbo C can't access any of the win32 api functions -- its too old of a compiler. Nor can you use any modern GUI library like QT Gui tools previously mentioned.

About the best you can do with your compiler is to just call printf() to display the message. You might also write your own function that would erase a rectangle on the screen, put a box around it, then print the message inside that rectangle.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Neither of the code snippets you posted compile. This is your second example with a couple changes so that I could make it compile, but it also has a problem.

The operator << has two parameters, but main() is passing only one parameter. Fix that and both examples will compile.

#include <iostream>

using namespace std;
struct RGB
{
    int R, G, B;
};

inline std::ostream& operator << (std::ostream& Str, const RGB &Rgb)
{
    Str<<"R: "<<(int)Rgb.R<<"  G: "<<(int)Rgb.G<<"  B: "<<(int)Rgb.B;
    return Str;
}

int main()
{
    RGB Rgb;
   cout<<Rgb(16777215);      
triumphost commented: Thank you +5
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

So, what have you done in the past 16 hours to solve this? (It's been 16 hours since you posted this question). Do you need all the data in memory at the same time, or can you work with one row of data at a time? The difference is the size of array that will be needed. After you determine that, it is pretty simple to read the numbers into an array by just calling fscanf() in a loop.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Go to Geek's Lounge, then click the Last Post Date on the thread titled "What jobs are available for a person with a MIS degree"

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I get that error when I click the date of loast post in this thread. Doing that on other posts seem to be ok.

http://www.daniweb.com/community-center/geeks-lounge/threads/107097/what-jobs-are-available-for-a-person-with-a-mis-degree

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't actually code them as you posted them because the second line will produce a "redefination" error message. Once a macro has been defined you have to undefine it before it can be re-defined.

#define PRINT (a,b)cout<<(a)<<(b)
#undef PRINT
#define PRINT (a,b,c) cout<<(a)<<(b)<<(c) /*trouble?:redefines,does not overload*/

You don't have to define macros at the beginning of a program -- they can be defined, undefined, and re-defined anywhere you want to do it. The compiler will use the most recent definition when compiling the remainder of the program from the point that the macro is defined to the end of the program file.

Macros are evil beasts. One reason is because of what I just said above, that macros can be redefined anywhere in the program making it difficult for a programmer to figure out why something went wrong.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you include the <sstream> header file as I posted with my example?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you certain p2 is an open FILE pointer?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

void ProductSummary::ReadProductFile(ProductSummary, ifstream& in_file)

Delete the first parameter to that function, its not necessary to pass it. Also in that function use stringstream class to parse the line into its individual words instead of using the string's find() method. stringsteam is a whole lot easier

#include <sstream>

...
..

void ProductSummary::ReadProductFile(ifstream& in_file)
{


    //Names of all of the strings to be read in
    string 
        file_input,
        nextPlanner, 
        nextCommGrp, 
        nextSalesGrp, 
        nextPartNum, 
        nextAvgPrice, 
        nextNumSold, 
        nextPartTotal;

    getline(in_file, file_input);
    streamstring str(file_input);
    getline(str, nextPlanner, ',');
    getline(str, nextCompGrp, ',');
    getline(str, nextSalesGrp, ',');
    getline(str, nextPartNum, ',');
    getline(str, nextAvgPrice, ',');
    getline(str, nextNumSold, ',');
    getline(str, nextPartTotal, ',');
    Planner = nextPlanner;
    CommGrp = nextCommGrp;
    SalesGrp = nextSalesGrp;
    PartNum = nextPartNum;
    AvgPrice = atof(nextAvgPrice.c_str());
    NumSold = atoi(nextNumSold.c_str());
    PartTotal = atof(nextPartTotal.c_str());


}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

if any process has the file open when this happens, deletion is postponed until all processes have closed the file.)" The part in parenthesis is what I take advatage of for this.

That is a BAD habbit to get into. That behavior doesn't work with all operating systems. For example remove() doesn't work like that on MS-Windows. Don't attempt to delete the file until AFTER you are finished with it and the file has been closed.

Should I still remove the spaces for %d and %s?

Yes. There should be no spaces between the % symbol and 'd' or 's'.

in regards to 104 thats where I was forgetting correct pointer syntax.

you want to call strcpy() to copy the string into name: strcpy(finder->name, symbol);

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what's the operating system you are using? When you downloaded CB did you download the version that contains MinGW compiler? If not, what compiler are you using with CB?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Below is how to use fscanf() in a loop to read all the words in the text file. Notice that I did NOT have to call feof() because fscanf() will return an integer less than or equal to 0 when eof is reached. This is a more efficient way to check eof than using feof().

while( fscanf(file,word, sizeof(word)) > 0)
{
   // got one word, now check if it is the longest word
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Today (not in legacy code), you should only find new/delete or malloc/free calls in the guts of some library code (

That is very surprising! I haven't written professionally for about 5 years now, and I am surprised to find that it has changed that much. I have not read much about c++11 yet.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Read this thread and it will tell you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you just want the longest word then read the file one word at a time, not the entire line. Do that with fscanf(). After a word is read all you have to do is call strlen() to get the word's length and compare it with the length of the most recent longest word that was read in the past.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

See this thread for an example of how to use fork() As for what fork() does -- you can read this man page

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 8: I'd make that an unsigned int instead of int because addresses should never be negative number.

line 41 p2 = fopen("argv[start]","r");

remove the quotes from around argv[start] -- the compiler thinks that is the actual filename, not a variable that contains the file name.

lines 35 and 36: Why are you opening a file then attempting to immediately delete it? unlink() will fail if the file is open.

line 44: Remove the spaces in the format specifier, e.g. it should be "%d%s". There should not be spaces between % and d or s.

line 44: Yes, the same line as above. The = EOF at the end should be == EOF because you want the boolean operator not the assignment operator.

line 104: That line is confusing. Why are you tring to store an integer in the first byte of a character array? That may work if the value of the integer is less than 126, which is the largest positive value that can be stored in a char data type. And is the first few bytes of variable symbol all numeric digits?

There are more than likely lots of other problems with that program I have not found.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what operating system? In MS-Windows I think what you want is to create a caret

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I know of no good reason to use malloc() in a c++ program unless you are porting some old legacy program from C to C++. I don't think Tumlee said if can't be used, just that there is no reason to use it. In some cases malloc() can't be used.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 11: start the value of j = i counter instead of 1

line 14: print the value of j not i, and do not increment it on that line. It will be incremented on line 11. Finally, put a space in the format specifier so that there is a space between the numbers printed on the screen.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You try it first and post your best shot. You should know that a for loop is coded sometime similar to this: for(int i = 0; i < 5; i++). All you have to do is substitute the variables in what I just posted with what you posted.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

can any one help to create an dynamic (2*10) two dimensional array using new and delete?

Yes I can. It reuires a loop, and the pointer needs two stars, such as int ** array; Lets say you want to create a spreadsheet-like array with 2 rows and 10 columns. The first thing you have to do is allocate the number of rows, like this: array = new int[rows]; Then you start a loop for each row, within that loop allocate the columns for each row

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well, maybe I need a hearing aid??

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Mine's ok on Chrome.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a youtube video of the hail storm I had today. It has no audio, so don't toss out your headphones thinking they are broke :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Oh nevermind. I think what is confusing me is that instant preview that shows up when I click in the edit box.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I just have to cast the void pointer every time I want to use it as a byte type?

hMapFile is NOT a byte ptr -- its HANDLE which is already the type returned by CreateFileMaping(). And where do you see a void pointer??? I don't see that sort of object in the code you posed.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Depends on the compiler you are using. If you are using Turbo C++ then you can't code the using namespace std: option because that compiler doesn't understand it. You have to use fstream.h with that compiler.

If, on the otherhand, you are using one of the modern c++ compilers then you have to use <fstream> -- without the *.h extension.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The replacement for the Quote button (mouse left click to add text already in clipboard) is really very annoying at times. If all I want to do is just put the cursur somewhere, such as at the end of the last line of text already inside the edit box, your edit box copyies the clipboard text there too. Any way to prevent the edit box from doing that?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You need to put break statement on lines 27 and 30 so that if you select Login the program won't make you register also.

and 1 tips fom my side that opening file mode instead of "wb+"..use "w".

No. "wb+" is correct in this program because the structures are being written in binary mode using fwrite().at line 67.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are trying to convert the return value of CreateFileMapping() to the wrong type. It already returns the correct type, so no typecasting is needed.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

my answer to "What kind of device is IPad?" was "Crappy".

LOL :) :) I might have answered "i don't know", but then I'm not as smart as a 5th grader (an American TV show)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Don't get me started of petrol prices in the UK ! I'm spending £60-£70 on the stuff in an average week at the moment.

I think I would ditch the auto and ride a bike. That's terrible price for petro.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The whole purpose of the up/down arrows is to let members vote anomously and avoid giving rep. IMO its just as easy to enter a comment if you want to give rep and I see no reason to change the system.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Good :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I hate *nix -- its just too complicated for me. I like the ease with which I can accomplish things in Windows. For example, yesterday I decided to install Ubuntu because there was a problem I wanted to test out on *nix. That all went well, until I tried to access the internet. NOT. I have wireless connection and Ubuntu didn't have the drivers for wireless, all it recognized was wired connection. So I booted back to Windows and did google search for the problem. Lots of problems came up but no solutions. Fortunately, a couple weeks ago I created an image of my computer (Windows control panel option) and saved it onto an external hard drive. So today I deleted the Ubuntu partition and had Windows restore the computer image -- about 2 hours work for the computer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

http://www.daniweb.com/software-development/cpp/threads/332761/ide-linux

Something strange is going on here. When I click IDE \&amp; Lunix | DaniWeb
from the google link all I see are empty posts -- posts that have no text. But when I go to that same thread directly within DaniWeb everything is ok.

Same problem with all the other DaniWeb links in that google page.

[edit] Can't post "&" without the editor changing it to "&amp"

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
  1. line 9: when calling a function do not include the [] in the parameter list
    search(array1,array2);

  2. line 13: sizeof does not work for pointers and arrays declared as parameters. sizeof(array1) will always be 4 in 32-bit compilers because array1 is a pointer, not an actual array. sizeof only works with arrays in the same function in which the array is declared, main() in your program. The way to do it is to first declare a macro at the beginning of the program with the desired size, then use that throughout the program. For example `#define SIZE 100

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In C language, before version c99, you have to declare all objects at the beginning of the block. Reverse the order of lines 8 and 9 so that the declaration of pFile is the first thing in the function. C++ does not have that restriction.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Maybe you don't understand what I'm talking about. See thumbnail Untitled36