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

Well, just so you aren't trying to trick us, you post your code first then someone might post his/her code. If it's too large then just zip it up and attach it to your post.

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

You might go over there and take him swimming with concrete shoes :)

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

You will find the explanation of them all here

while(cin.get() != '\n')

The above is getting characters from the keyboard one at a time until '\n' (Enter key) is reached.

rubberman commented: Good link, C++.com - I keep a tab open to it in my browser all the time! :-) +12
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 8 is nonsense -- no one in his/her right mind would do such a thing. Useless statement.

line 7 might be a problem without typecase.
p = (char*)arr;

line 9 will NOT print the value of arr[0] as you might expect. p is a char pointer, so *p will return only the first byte of an integer.

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

yes -- printf() will attempt to use it.

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

The code has undefined behavior because check() is returning a pointer to an object that doesn't exist after check() returns to it's caller. That is illegal in C and C++.

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

You mean you created over 3,000 youtube videos???

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

Ignoring optimization, I would say code 2 is minutely faster because it doesn't have to initialize the inner loop as often as code 1. Other than that, they are both the same.

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

char* name is a pointer, while char name[] is illegal because it is attempting to create an array of 0 elements. Some compilers may support declaring arrays with 0 elements, but that is an extension of the standards. It's quite dangerous to use non-standard constructs because that makes the program itself non-standard and may not compile with other compilers. If you instructor or someone else wants to compile your program with another compiler it mahy fail.

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

Homework? A prototype tells the compiler about a function such as its return value and parameters. Function prototypes are required if the function has not been previously defined. For example

void foo(char* s)
{
    printf("%s\n", s);
}

int main()
{
   foo("Hello");
}

In the above snippet a function prototype for foo() is not needed because the compiler already knows about the function when it is called from main()

However, in the snippet below a function prototype is required because the compiler knows nothing about the function foo() when it is called from main().

 void foo(char* s); // function prototype

int main()
{
   foo("Hello");
}

 void foo(char* s)
 {
     printf("%s\n", s);
 }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If this is your first job and applying for entry level position then don't be overly concerned about your technical skills. Companys don't expect you to be expert for entry-level job. Have you finished your college bachelor's degree yet? That, along with the other things Jorge mentioned are what you should concentrate your efforts on. I decided not to hire one person because of lack of social skills not because of technical skills. You have to be able to work well with others and accept gratiously the critizem of your work from your peers becuase there will be peer review of the code you write.

iamthwee commented: nods +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't need a gun to live so this is an incorrect comparison.

You will if you live in St. Louis, Missouri or Washington D.C.

You people only hear about high crime rates in the big cities of America. There are millions of people living without fear all over the country, living in small towns and rural areas. I am one of them -- the town where I live has a population of about 2,000 and the only crime we have had since I moved here in 1979 is kids playing pranks on Halloween. I don't even lock the doors of my home when no one is home for a few hours or when I am sleeping. And I list just a few miles outside of St. Louis, which has one of the highest crime rates in US.

On Thomas Jefferson Quotes

"No free man shall ever be debarred the use of arms. The strongest reason for the people to retain the right to keep and bear arms is, as a last resort, to protect themselves against tyranny in government"

-- Thomas Jefferson, 1 Thomas Jefferson Papers, 334

(At the time that was written America had large slave trade, "fee man" generally referred to white people, not black slaves, although there were a few white slaves too.)

The people of the various provinces are strictly forbidden to have in their possession any swords, short swords, bows, spears, firearms, or other types of arms. …

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

This article may give you some hints to how you can do it. It creates a splitter window with a tree-view in the left side and something else in the right side. Maybe you can embed IE in one of the two sides. Here is how to embed an IE browser in a program. It is quite complicated so be prepared to learn a lot of COM programming.

It will be a lot easier if you use C++/CLR which is for .NET so that you can use it's browser control.

Unimportant commented: Solid post +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There's no such thing as an integer with only 2 bits -- maybe you mean bytes instead of bits.

The number of bytes in an integer depends on what computer hardware architecture and compiler you are using -- c and c++ language do not specify how many bytes are in an integer -- it only says there is one byte in a char data type. Some 16-bit compilers such as Turbo C uses sizeof(int) is the same as sizeof(short) and sizeof(short) is two bytes. When you move to a 32-bit compiler such as modern gcc and Visual C++ you will find that sizeof(int) is the same as sizeof(long), which is 4 bytes while sizeof(short) is 2 bytes.

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

One way to do it is to first allocate the number of rows you want, then for each row allocate the columns. As you can see the memory for the array is not contiguous.

int rows = 5;
int cols = 10;
int **array = malloc(rows, sizeof(int));
for(int i = 0; i < rows; i++)
   array[i] = malloc(cols, sizeof(int));

display(array,rows,cols);

how are we able calculate the adress of a[3][4] given the address of a[0][0] ? how are we able calculate the adress of a[3][4] given the address of a[0][0] ?

That's not possible with my code above

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

Even a simple list by country or a pie chart would be interesting.

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

I wan't able to get email working with WampServer so I uninstalled it and installed Uniform Server, which has SMTP by default, and works well (or at least good enough for my purposes)

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

You might also check the documentation for the specific compiler you want to use, for example if you use Microsoft Visual Studio then read this article. I'm sure GCC has a similar page.

christinetom commented: Thanks for the help +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

As C doesnt provide direct serialization

Serialization is nothing more than a fancy word for read/write to a file stream, whether the stream is the console screen, a file system, serial port, internet connection or something else. In your case "serialize" just simply means read/write to a file in the hard drive.

C langusge supports both binary and text files, you choose the file type in the second parameter to fopen(). "wb" means "write binary" while "w" or "wt" means "write text". The same with reading -- "rb" is "Read binary" and "rt" or "r" means "read text"

If you have a structure and you want to write it in binary mode then just do something like this:

#include <stdio.h>

struct foo
{
   int x,y,z;
   char something[255];
}



int main()
{
   struct foo fooArray[8];
   // open the file for binary writing
   FILE* fp = fopen("filename.bin","wb");
   if( fp != NULL)
   {
       // write out the entire array in binary
       fwrite(fp, fooArray,sizeof(fooArray));
       fclose(fp);
    }

    // now read it back
   fp = fopen("filename.bin","rb");
   if( fp != NULL)
   {
       // write out the entire array in binary
       fread(fp, fooArray,sizeof(fooArray));
       fclose(fp);
    }


}

You apparently just have a void* so you will have to typecast it to char* in the fread() and fwrite() functions. The last parameter to those functions are the number of bytes to read/write, so I hope you have that info too.

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

Is there a reason you want to use that library instead of just standard C FILE* functions? If all you want to do is write it to a file then just standard C library fwrite(), then fread() to read it back. You won't get more efficient then that. But if you want something more complex such as memory mapped files then maybe that library will do. Just scanning over the contents of the header file the library looks to be much more than what you need.

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

jump is a macro which is defined to be the name of a register -- you can use register names as labels. Suggest you just delete lines 3 and 4.

lines 8 and 9 should appear after lines 10 and 11. The way they appear now lines 8 and 9 will always be executed regardless of the outcome of lines 10 and 11. Is that your intent? Probably not.

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

why? Is there also a Cloud based compiler to go along with that Cloud based editor? Why not just use the editors that already exist on your PC?

[edit]I just read about it in the link you provided. It might be ok for web programming (HTML, java, etc) languages which do not need a compiler.

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

According to Sams, it will only take 24 hours, see Sams Teach Yourself Java in 24 Hours.

ddanbe commented: Good thinking! +14
iamthwee commented: lol +14
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

One of the best resources for MS-Windows programming examples, tutorials, and free code is found on codeproject.com

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

call Directory.GetFiles() as shown here. But be warned that this will take a long time to search your entire hard drive for the files you want. It would be a lot faster to use an MS Access or other SQL database to keep the links to the files.

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

Movie collection system. Read barcodes from movie dvd, look up the information (actors, description, etc) on the internet, and create a local SQL server (e.g. free MySQL) database of that information. You could do lots of stuff with this such as search for specific movie, produce a list of all movies in the database sorted in any order the user wants, or even play the movie.

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

I don't use it because AFAIK none of my Facebook friends are programmers (well, there is one exception) -- they wouldn't know what the question and DaniWeb is let alone be able to answer any of the questions.

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

lines 26-28: you can't put functions that have no return value in cout statements. What do you expect cout to print? It can't print what the function doesn't return.

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

but still and still, i am very very optimistic guy.

Think of it as you would when you use a paper shredder to destroy documents. Once shredded there is no way to replace the document (assuming there are no other duplicate copies). You are just SOL.

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

Each compiler has it's own implementation of malloc(), but the ones I've debugged (stepped through the assembly code to find out how it does it) initially has a large block of contiguous memory. malloc() it tries to find a free block that is as close as possible to the amount of memory you requested plus some memory for it's own use such as pointer to the next free block of memory and the size of this memory block. So if you request 8 bytes and the smallest available free block is 16 bytes then malloc() might return a pointer to that 16-byte block of memory. When you call free() the compiler puts a pointer to that block back into the free-memory pool so that it can be given out by malloc() again. Some compilers may try to optimize the free memory pool by combining adjacent blocks of memory, defragment the memory, but tha is not always possible.

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

Solved the problem. The tutorial added the database file as a resource. When the program starts vb.net copies the database file from the resource into the destination director, in my case it is \Documents folder. I created a new project but did not add the file as a resource. Everything works as expected now.

Begginnerdev commented: Awesome! +8
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'll sell you some dribble :)

Reverend Jim commented: That's just awful. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The statement simply states "syntax error in INSERT INTO statement"

I got (bought) this eBook which gives a complete example, and the example ALMOST works, it retrieves all the data into the Grid, and attempts to update the database. After adding a row to th Grid, the program calls DataAdapter.Update() and it's feturn value (1) seems to be correct, there are no exceptions thrown, but when I check the table it has not been changed.

Begginnerdev commented: You've got to love those non-descript error messages. +8
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have no clue why, I have not had a biology class since about 1960. But you might be interested in this article, which suggests diamond mines are covered in asbestos dust

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

don't you guys wear masks when working with those diamonds?

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

Researchers interviewed 115 lung cancer patients

This whole story is nothing more than bullshit.

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

When I click the Endorse button everyone shows up in just some random order which makes it kind of difficult to find a specific person. Can (or will) you sort the list alphabetically to make it easier to find someone?

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

I do not understand why did you make 3 for loops?

And I do not understand why you responded to a 6-year-old thread

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

Granted, but since everyone else got an A++ your grades are on the very bottom.

I wish I had a new Lamborghini car.

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

I started wearing glasses when I was in 9th grade -- nearsighted. I started computer programming in my 40s and got a lot of eye strain from staring at those green monitors -- it was really painful. Monitors are a lot better today with almost no eye strain at all.

You're only as old as you feel, and I feel as if I am in my 40s most of the time. Yes, I still like to play video games.

cproger commented: haha +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your example is incomplete/incorrec -- where is the variable i changed? Answer: it isn't, so the output you posted is wrong. The correct output is "111111111..."

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

Most of that is due to one guy I know :)

Reverend Jim commented: I love it. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Read this

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

Dawn of the computer age is mostly responsible for obese children, all they want to do is sit playing on a computer or texting. Even their brains are getting fat due to lack of use, such as learning to do math in their head instead of on a calculator. Some day in the future man will evolve without brains due to lack of use.

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

Contrary to what you might think the Patriot Act did not replace the 4th amendment -- the 4th amendment is still alive and well. What it did was give the government broader powers to search and seize.

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

Here's an article about why we don't let just anyone bring anything across our borders. We've had too many problems with people knowingly or unknowingly bringing diseased agriculture products here. And some states do not allow fruits to be brought across state borders. I recall 40 years or so ago my mom and dad took a trip to Arizona and a border guard took her orange she was eating!

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

So in my output file, I would like the data to look just like dropsOf[][] with 4 rows and 5 columns

Yes, you need two loops for that, one for the rows and the other for the column s

for(int count = 0; count <= numRows; count++)

Wrong. count goes up to, but not including, NumRows. Count them on your fingures if you have to -- 0, 1, 2, 3 and 4. That makes 5 columns. There is no such column number as NUM_COMPONENTS (which is 5 in your program). You have the same problem with the inner loop.

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

In America there is the Bill of Rights, or something like that, which makes it very unlikely that a personal computer could be investigated without good reason.

It's the fourth amendment to the us constitution

The right of the people to be secure in their persons,
houses, papers, and effects, against unreasonable searches and
seizures, shall not be violated, and no Warrants shall issue, but
upon probable cause, supported by Oath or affirmation, and
particularly describing the place to be searched, and the persons or things to be seized.

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

ofstream must be passed by reference, not by value as you have done. Not: don't use a calculated value in the loop condition because it is calculated on every loop iteration. Make the calcuation before the loop starts then use it in the loop condition, as shown below.

void storeProportions(ofstream& output, int values[][NUM_COMPONENTS], int totals, int numRows)
{
    double finalOutput = 0;
    int maxnum = numRows * NUM_COMPONENTS);
    for(int count = 0; count <= maxnum; count++)
    {
        output << values[count][NUM_COMPONENTS] / totals) << endl;
    }
}

The above code still is incorrect because there is no such element as values[cound][NUM_COMPONENTS]. Are you attempting to write all the array values to a file? If yes then you will need two loops

    void storeProportions(ofstream& output, int values[][NUM_COMPONENTS], int totals, int numRows)
    {
        double finalOutput = 0;
        for(int count = 0; count < numRows; count++)
        {
            for(int j = 0; j < NUM_COMPONENTS; j++)
            output << values[count][j] / totals) << "\t";
        }
        output << "\n"; // new line
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The second parameter is incorrect -- do not specify the dimensions

storeProportions(output, dropsOf, totals, numFailed); //located in main