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

Is there any way of running and compiling with known errors in the code.

Compiling? yes, running? No because the program has to be error-free in order to execute the code. There is no point in trying to execute a program that contains compile-time errors. How do you expect the compiler to generate executable code when the source code is crap?

Do you really need references to both versions of word at the same time? If you have the reference to word 2010 just test your program on a computer that has word 2008 installed on it.

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

Same answer as in your other thread here.

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

You need to post the code you wrote. I (we) don't do your homework for you unless you deposit $1,000.00 USD in my PayPal account.

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

line 24 is wrong. %s need a pointer to a char array, not a single character. What you need is %c instead of %s.

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

what are the errors? And what compiler and operating system?

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

why is it that the c2.LunchTime() triggers the copy constructor?

Because the function is returning an object and the only way to return it is by making copy of it. If you changed it like this then the copy constructor would not get called because the function would return a reference to itself.

Clock& Clock :: LunchTime () {
    hr = 12;
    min = 0;
    sec = 0;
    return  this ;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 1 and 3 are not valid statements. Also, there is a memory leak on line 4 because it doesn't delete the pointer allocated on line 2.

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

line 8 points to an address that was deleted in line 7. Once the memory is deleted you can't reference it again.

RonalBertogi commented: This explains well DaMaskMan2's question. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you want to save the structures then don't use pointers in the structure. Below is an example of how to read/write the structure in binary files. Note that to open the file for writing you will probably want to use other flags than "wb" because "wb" will not save existing data. Read all about those flags here.

typedef struct friends_contact{

  char First_Name[40];
  char Last_Name[40];
  char home[60];
  char cell[15];
}fr;


// save the strcture
fr data;
// fill in the structure, now write it to a file
FILE*fp = fopen("file.dat", "wb");
fwrite(&data, 1, sizeof(fr), fp);

// read the structure from the file
FILE*fp = fopen("file.dat", "rb");
fread(&data, 1, sizeof(fr), fp);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post what you have done so that we can help you. I would probably read the contents of File B into an array in memory then search that array for each line in File A.

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

you'll have to post the code.

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

Post your program

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

It doesn't matter how you exported it or what lib you linked to since you can't create a vector in a dll and expect to destroy it in the application program because of heap differences. Won't work. You need another method in the DLL that will destroy the contents of the vector when no longer needed.

std::vector<std::string> Editor::StringHandler::Split(std::string data, std::string tokens)

You don't want to return a vector like that because it has to be duplicated when returned, which can be very very time consuming. Instead, pass a reference to the vector as a parameter so that Split can just modify it. Return either void or maybe bool to indicate success.

bool Editor::StringHandler::Split(std::vector<std::string> & returnList, std::string data, std::string tokens)

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

i want the array(totalwin) t

You mean totalsum, there is no variable named totalwin

line 46 is saving the same value in totalsum three times. If you want each element of that array to contain the value of sum each time the loop repeats then you need a loop counter that only changes once each time the loop repeats. For example:

int main()
{
   int index = 0;
   ...
   ...
   totalsum[index] = num[0] + num[1];
   printf("Addition amounts to %d\n", totalsum[index]);
   index++;
   ...
   ...
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 288: Where is the memory being allocated for the members of that structure? All I see is unallocated pointers, which is why your program crashes when it tries to execute that scanf(). scanf() doesn't allocate memory, you have to do that yourself before calling scanf(). One way to fix the problem is to use temp buffers for scanf() then allocate memory needed and copy to the structure members.

char lname[40], fname[40], ... // etc for each item
fscanf(read,"%s%s...", lname, fname ...)
friends.first_name = malloc(strlen(fname)+1);
strcpy(friends.first_name,fname);
// etc for each structure member

Don't forget to free() the memory somewhere in your program to avoid memory leaks.

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

New memory allocated in a DLL must be deallocated in the DLL. You can't allocate memory in a DLL then deallocate it in the application program because the two have different memory heaps.

Here is another thread on that topic.

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

See this tutorial. You need to bookmark that site codeproject.com because it has probably the largest repository of free MS-Windows Visual Studio code on the internet.

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

Reading looks to be ok, what you need to do is move lines 29 and 30 inside the loop so that it prints each of the lines.

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

Look in that file (afxcmn) and check line 544. Most likely its a NULL pointer or invalid HANDLE that is being passed to it. I don't have that file installed on my computer so I can't check it for you. Put a break point in your program where it calls the function in afxcmn then verify the validity of the parameters your program is passing.

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

That's exactly the purpose of loops. There are three types of loops
1. for-next
2. while
3. do-while

To answer your question, all you have to do is put one of those three around lines 7-11, enclosing them in { and }. Look up loops in your textbook for further explanation.

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

No, but if your math skills are up to par you should be able to figure it out from this article.

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

Your algorithm for that function is incorrect. According to this article, you have to double every second digit.

It's not clear from that function whether it is validating the account number or calculating a checkdigit. If you are validating the account number there is no need to calculate the checkdigit because the checkdigit is the last digit of the account number.

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

The people who post om Facebook, especially the ones I haven't seen for a long time.

especially my little brother's. he's just 6 months old.

I hope you still feel that way when he's 15 :)

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

i want a book or dvd explains every tool fully with the pictures

I don't think there is such a thing. MSDN gives code exmples for most of the functions they document. It's not their job to hold your hand while you learn how to use the tools. If you don't understand something then write a small test program to test it out.

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

for 2 and 3 would you please give me code? i'm new in c++

No. You give it a try then post the code you have written and ask questions about what you don't understand. Asking me to do your work for you will not teach you a thing.

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

A complete reference is online at Microsoft's site MSDN (Microsoft Developer's Network). Just google for the name of the tool you want to know about. For example if you want to know about the editbox, then google for "msdn editbox"

If you can spend some money then you can buy a book from amazon.com that explains them. See this link

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
  1. use a char variable

    char filename[255];
    getline(cin,filename);
    ifstream in(filename);

  2. read each line of the file. When a line is read search it for the desired text. In c++ you can use std::string's find() method.

  3. You have to completely rewrite the file, leaving out the line you want deleted.

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

which line?

cin>>c>>endl;

Line 21: endl can not be used cin, it's only useful for outpout streams, not input streams.

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

I quote you using '>', line break, and then I start typing; It still sees WHAT I AM TYPING as a quote. I dont know if this is a IE9/W7 bug....

Just use two line breaks instead of one. Problm solved.

Here is the thing: Users love the lipstick. They dont care if there is a pig behind it. Thats the developers problem.

LOL :)

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

Robert Kennedy??? What did he do, other than get shot, that made him so great? Even getting killed isn't really so great, lots of people get killed every day.

John Kennedy wasn't so great either, he wasn't President long enough to achieve that status. His presidency was pretty normal for its day. Bay of Pigs was a disaster.

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

No one said you have to use intellisense. I don't use it, or very seldom use it. Intellsense was broken on VC++ 2010 but I think the bugs were worked out in 2012. As for the debugger, I use it often. If you don't have to do any debugging then you are one of the most brillient coders on the planet :)

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

what have you tried?

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

fgets() read the <Enter> key into the buffer if the buffer is large enough to hold it. It's done that way by design so that the program can tell whether all the line was read or not. If the '\n' exists at the end of the line then the entire line was read. If '\n' does not exist at the end of the line then that means the buffer was not large enough to hold all the line and fgets() should be called again to finish reading the line.

What your program is missing is to remove the '\n' from the buffer. One way to do that on line 13 is like this:

char* ptr;
if( (ptr = strrchr(sentense,'\n')) != NULL)
   *ptr = '\0';
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

depends on the operating system and compiler you are using. There is no standard way to change background color because that is a function of operating system.

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

CreateList just copies the input file to the output file, it does not retain any of the data or create a linked list. The loop starting on line 146 will do nothing because myHead is NULL.

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

line 81. After you enter a number and press <Enter> key, cin does not remove the enter key from the keyboard buffer. Then when getline() is executed at line 9 it sees '\n' in the keyboard buffer and removes it thinking that is the end of the text you just typed. To correct the problem, after entering an integer, float or double you have to remove the '\n' from the keyboard buffer. There are several ways to do it, the safest way is to flush the keyboard buffer of all keys. Read this thread about how to flush the keyboard buffer.
'

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

line 9 is doing integer division, which means all declimals are discarded. With int division 1/2 is 0, not 0.5. To correct that you have to promote either numerator or denominator (or both) to float our double.
c=(int)((float)a/b*100.0);

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

I've been using 2012 for a couple weeks now. It isn't much different that 2010, except you can't get just VC++ 2012 like you could vc++ 2010. Instead, you get the whole Visual Studio suite of compilers. I had VS2012 RT and VC++ 2010 installed at the same time and had no problems. Another difference: vc++ 2010 has support for CLR/C++ Windows Forms, VC++ 2012 does not. M$ dropped it for some unknown reason. vc++ 2012 will still compile the windows forms code, but you just can't start a new project with the wizzard.

work with VS 2010, which was extremely frustrating,

Yes, there's a bit of a learning curve if your accustom to gcc compiler.

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

but you're making yourself look a bit of an angry eric.

More like looking like a fool. He's the only one out of the 1,000,000 members who is complaining so hard about things. I think he is just trolling.

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

Corrected function. nevsor_t is NOT a structure, it's a typedef, so you don't use the struct keyword with it. Also, there is no * before ia->age because ia is not a double pointer.

    int sort_age(const void *a, const void *b)
    {
        nevsor_t *ia = (nevsor_t *)a;
        nevsor_t *ib = (nevsor_t *)b;

         return ia->age - ib->age;
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

_A_FUNCTION is not the same as _A_FUNCTION(), read this article

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

This is another intresting one: Hightlight text you want to quote, hit quote, and it gets quoted two times. Once again, the fine programmers of Daniweb...

Huh? When you hit Quote in the bibbon above the editor you get the following, which you need to replace with the text you want quoted. A little more awkward than it was in vBulletin, but its just easier to type the > character instead of hitting the Quote button then backing out the "Quoted Text Here" text.

> Quoted Text Here

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

it will if it's indented or tabbed at the beginning of the line.

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

lines 16-23 are incorrect. The loop also needs to check for end-of-list so that it doesn't attempt to iterate past the end of the list when item does not exist in the list.

currPtr = head;
while (currPtr->next != NULL && currPtr->next->datum != item)
{
    currPtr = currPtr->next;
}
if( currPtr->next != NULL)
{
    deletePtr = currPtr->next;
    currPtr->next = currPtr->next->next; // remove the node from the list
}
else
    deletePtr = NULL;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Implementing the add() function is pretty simple, just assign one of the elements of aNames and aNumbers from the two parameters. For example: aNames[i] = name.getname();

Is class Phonebook right? The find() method is supposed to return a reference to PhoneNumber class, but PhoneNumber is not in Phonebook. I'm thinking aNumbers should be an array of PhoneNumbers, not an array of std::string. Either that, or find() should return a reference to std::string, not PhoneNumbers.

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

Oh I see :)

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

the select all functionality doesn't work when you print the website out on a piece of paper and try do it

Huh? How can you do select all from a piece of paper???

noticed this and I tried to "Select All.........Copy" the textbox. ITS IMPOSSIBLE TO DO. Keyboard shortcuts

Blaim Microsoft, not DaniWeb.

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

You mean Visual Studio 2012?

There are two versions of Visual Studio 2012, one for desktop and one for Windows 8

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

so where would I find the syntax to display

Think about it, look up printf() function in your textbook or online using google. Hint: strlen() returns the length of a string.

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

What's the question(s)? The code you posted doesn't even start to do the assignment.

Hint: use fgets() instad of scanf() when you want to enter a string that contains spaces. For example:

char name[255];
printf("Enter your first name, middle name, and last name\n");
fgets(name, sizeof(name), stdin);

Another way to do it would be to use three different variables

char lname[80], fname[80], mname[80];
printf("Enter first middle and last names\n");
scanf("%s%s%s", fname,mname,lname);