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

I was thinking that too -- I have a Chinese medical doctor whose last name is Hu.

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

The variable total on line 11 hides the variable total declared on line 10. Just delete parameter total on line 11.

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

I guess I have found the limit of a overload.

That's not the problem. Lines 43-46 pass 5 arguments, line 11 wants 6. Remove the last argument on line 5 and make total local to that function. But what is that function doing with total? It's a useless variable that disappears as soon as the function returns.

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

Looks like the problem is repeatValue() template. Why is that a template?

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

When I try to compile my code in visual basic 2010 it gives me the error 1903

I think you meant to say Visual C++ 2010

Error 1903 just means there were too many previous errors and the compiler gave up. Usually the first error is the most relevent.

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

that says nothing about not being able to use VT_EXPANDTABS with DT_SINGLELINE or DT_VCENTER. The link you posted is the same one I posted. If you want to use '\n' or '\r' then you have to parse it yourself and split the line at '\n'

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

Did you try DT_EXPANDTABS ?

DT_SINGLELINE
Displays text on a single line only. Carriage returns and line feeds do not break the line.

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

In c++ a struct is nearly identical to a class. Just rename the struct to class and make members public

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

The second one is because l_aAPtr is an array.

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

ut why the double don't accept integers?

It has to do with what the compiler pushes on the stack. Integers are 4 bytes on the stack while doubls are 8 bytes. You told va_arg that the parameters are doubles and va_args attempt to get 8 bytes off the stack.

arning: command line option '-std=c++11' is valid for C++/ObjC++ but not for C

Does that file have *.c extension or *.cpp extension.

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

line 54 is sending 3 integers, not 3 doubles. Make them doubles and see if that solves the problem.

double a=average(3,10.0,50.0,6.0);

cambalinho commented: thanks for all +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post how you are calling that function.

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

MessageBox() does NOT return a double. Look it up.

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

When you get that kind of error just look up the function and see what arguments it expects. Simple use google to do that. In the case of _vscprintf() you are passing the wrong arguments. (link)

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

We don't do homework for you. Post the code you have written and we'll talk about it.

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

student enter his name in digits no dought it is wrong

Not necessarily -- depends on where you live. In some places it might be perfectly legal to name a baby R2D2.

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

the _vsntprintf() link isn't working

You're right -- I must have copied the wrong url into the clipboard.

but why use it? what means?

I don't use it. there may be a compiler setting to change the default to something else, but I'm not sure about that. That's the only reason I can think of to use CDECL.

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

_cdecl is the default calling convention for Micosoft Visual Studio. There is no need to explicitly use CDECL.

_vsntprintf() -- wrong. (link). How is _vsntprintf() supposed to know the size of the first parameter???

Please study a tutorial on variable arguments, then you will understand how that function is working. vsntprintf () is doing all the hard work of combining all the strings in the last parameters to that function.

cambalinho commented: thanks +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Didn't you google for it? (link)

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

If the assignment is to concantinate 3 or more strings at the same time then lines 45 and 46 do not test that problem. So if this is a class assignment then your instructor might (or might not) mark you down for that. z = x + y + l is the correct way to test the assignment.

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

Change lines 45 and 46 back to the way you had it. There was no need to change that line.

z=x+(y+l);

Here is what I see when I run your program

Enter string = one

string is = one

Enter string = two

string is = two

Enter string = three

string is = onetwothree

There is no theoritical limit to the number of strings you can concantinate with that. for example

Enter string = one
Enter string = two
Enter string = three
Enter string = four
Enter string = five
string is = onetwo threefourfive

All I did to get the avove was add a couple more instances of your count class, removed all those blank lines, then change line 44 to this:
z = x + y + l + m + n;

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

Did you bother to try what I told you? You're english is good enough and you express yourself very well. This is the code I'm trying to tell you about.

 count()
   {
        str[0]='\0';
   }
count operator +(count x)
       {
            count t;
            strcpy(t.str,str);
            strcat(t.str,x.str);
            return t;
       }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

solution is simple: just remove the second parameter to that operatopr function and delete line 23.

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

Forgot to say that you can use real numbers in matix.

That's ok -- you can't put irrational numbers in an int anyway.

Finding the largest array of positive numbers should be fairly straight forward. Just cound the number of positive numbers until either the end of the row is hit or a negative number is found. You will probably need to use two other arrays to do that.

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

line 18: operator can only have 1 parameter.

line 3: uncluding all std like that causes a name conflict with your count class name. replace that line with using std::cout; or change the name of your class to something else.

After fixing those problems your program works ok for me.

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

Your program appears to be retaining one of the last answers

1 10
1 10 20
100 200
100 200 125
201 210
201 210 125
900 1000
900 1000 174

The problem is that you need to reset maxCaseLen back to 1 after the scanf(), between lines 12 and 13.

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

your answer for 201 210 is 174, should be 89 according to the example input/output in the instructions.

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

wonder why UVA doesn't accept my answer

How are we supposed to know that? You didn't even tell us what that program is supposed to do. And what is UVA? My guess University of Virginia???

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

The entire class is quite dangerous -- how can you be sure the results of line 43 will not overflow the size of str (line 7)?

line 20: What is the contents of str at that point? Hint: undetermined because you failed to initialize str in the constructor. Just setting the first byte to 'r' does nothing at all. It need to be set to '\0', which is what all the fucntions in string.h expect.

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

There is no reason to do all that shifting. Forget shifting, it doesn't do you any good.

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

So, all you have to do is to read 4 bytes then reverse them. The whole problem of endian-ness disappears if you write out the file as plain text instead of binary.

#include <iostream>
#include <fstream>
#include <vector>
#include <cstdint>
using namespace std;
int main(int argc, char *argv[])
{
    if (argc!=2)
    {
        cout<<"Invalid argument count, please provide a file name."<<endl;
        return 0;
    }
    fstream file(argv[1],ios_base::binary|ios_base::in);
    vector<int32_t> data;
    int32_t tmp;
    char buf[4];
    while (!file.eof())
    {//complicated i/o to ignore endianness
        file.read(&buf[3],1);
        file.read(&buf[2],1);
        file.read(&buf[1],1);
        file.read(&buf[0],1);
        temp = *(int32_t*)buf;
        data.push_back(temp);
    }
    for (size_t i=0; i<data.size(); ++i)
        cout<<hex<<data[i]<<endl;
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

When I do it your way I get everything inverted

I wasn't aware that endian-ness was the problem you want to resolve. My way is only useful if that isn't an issue.

Here's an article that, I think, shows how to determine the endian-ness of an operating system.

Here is a discussion about your problem. Pay attention to the function in the last post. All that's neccessary is to swap the bytes of the integer, not the bits in each byte.

consider the 4 byte hexidecimal number 0xbebafeca. on a big endian machine this would be stored in contigiuos memory as [be][ba][fe][ca], whereas on a little endian machine the format would be [ca][fe][ba][be]. viewed as an array of unsigned char, to reverse the byte order you would need simply to swap the first element of the array with the last and the second with the third.

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

You can't just remove a row from a statically allocated array, and it's a little tricky to remove a row from a dynamically allocated array.

For statically allocated arrays the best you can do is to copy the contents of all the rows you don't want to remove up to fill in the gap, then the last row in the array is considered unused.

For example: if you have an array of 10 rows, in order to remove row 2 you have to copy rows 3-10 up to rows 2-9 then somehow mark row 10 as unused. The array still has 10 rows, but your program would consider the last row as unavailable.

For dynamic arrays when you want to remove row 2, do it in several steps
Step 1. malloc() a new array the same size as the original but with 1 fewer rows.
Step 2. copy all the rows from the original to the new, omitting the row to be deleted.
Step 3. free() the original array
Step 4. set the pointer of the original array to be that of the new array.

realloc() might work here but only if the row to be deleted is the last row in the array, so it's not useful in your program.

longest subarray of positive numbers in one row

I don't know what you mean by that. Does it mean the array can contain both positive and negative numbers? Post a simple example to …

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

you can't shift an 8-bit char by 24 bits (line 20). What are you trying to accompolish? Why do any shifting at all? If you're attempting to read a 4-byte integer, why not just do it the simple way

int num = 0;
file.read((char *)&num,sizeof(int));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

my assignment code is not commented (in hindsight that was a mistake) and I do not understand it anymore.

I can't tell you the number of times I've heard that same story.

Sorry, but I can't help you with your question.

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

i want a full code

Sorry, you are not going to get it. We don't do people's homework for them.

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

c++ language itself does not have an api for database access. As a beginner accessing any SQL compliant database is probably going to be very challenging. Before doing anything you need to study the SQL language so that you know how to request data and update the database. Without that knowledge you will get nowhere. There are plenty of online tutorials that will provide you with that info.

Here is a tutorial that will guide you through the process of using Micosoft Access database via ADO library.

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

storedValue on line 13 is an object of each instance of the class. Each instance of intCell has it's own copy of storedValue. The objects on lines 34 and 40 are two different instances of the class, so they will not have the same copy of storedValue. If that is what you want (all instances have the same copy of storedValue) then you need to make storedValue a static member of the class.

class IntCell
    {
          public:
            IntCell() {} // <<<<<<<<<<<<<<<<<<<<<
            int read() const;
            void write( int x );
          private:
           static int storedValue; // <<<<<<<<<
    };

That will make storedValue just like any other global variable, so you will need to declare it as a global. Notice that you have to remove the initialization from the constructor so that the constructor doesn't destroy the current value when a new instance of the class is instatiated.

Somewhere near the beginning of the *.cpp file put this line:

int IntCell::storedValue = 0;

smitsky commented: Excellent advice as always! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

boost will be the most portable between MS-Windows, *nix and MAC. I'm not familar with the other two.

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

I bought my grandaughter a Surface for college about 6-8 months ago -- it's a tablet at more than laptop prices.

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

I agree -- I like to capitalize SQL reserved words and make everything else lower-case or a mixture of upper/lower case. That makes reserved words stand out.

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

depends on data type

sUserName -- string
iUserID -- integer

I don't write php or java, just c and c++.

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

That explains a great deal :) You are using Turbo C because you are a hobyist, not a student who is forced to use it by his/her university. Sorry, but I can't help you either because I havn't used it since about 1987 myself.

If you are still trying to write code for that old XT compatible computer, or for anything older than Windows XP then Turbot C should work ok. You might have a lot of problems on newer versions of Windows.

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

first line is pointer to an array of 5 integers

Those are char pointers, not integers.

The first line declares an array of unknown number of pointers, each pointer points to a memory block of 5 bytes.

The second line allocates a single block of memory with size n*5. This is much faster and more efficient than allocating each of the n pointers individually.

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

He's talking about animals, not people. Very vew people have helth insurance for their pets.

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

line 66 is wrong. Check it with my previous post.

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

The problem appears to be in this function

ListNode *LinkedList::insert(ListNode *item, ListNode *sortedList)

That function is destroying the original list. It should be inserting item into SortedList and returning SortedList. Instead, it is doing just the opposite.

One way to solve the problem is for insert() to create a new node and add to sortedList, leaving item list link intact.

ListNode *LinkedList::insert(ListNode *item, ListNode *sortedList)
{
    // If sortedList is empty or first member of the  sorted list
    // is greater or equal to item then item becomes the first
    // member of the augmented list

    if (sortedList == NULL || sortedList->value >= item->value)
    {
        //item->next = sortedList;
        return new ListNode(item->value, sortedList);
    }

    // Use recursion to insert the item at the right place in the tail
    sortedList->next = insert(item, sortedList->next);
    return sortedList;
}

You also have to change this function so that it can iterate through the entire original linked list. The problem is that the last line will cause a memory leak, so before changing head = SortedList you have to delete the linked list pointed to by head.

void LinkedList::sort()
{
    ListNode *sortedList = NULL;

    //
    // USE A while LOOP TO CONTINUE LOOPING
    // AS LONG AS HEAD IS NOT EQUAL TO NULL
    ListNode *item = head;
    while (item != NULL)
    {
        //
        // TO MOVE POINTER TO NEXT
        sortedList = insert(item, sortedList);
        item = item->next;
    }
    head = sortedList;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

should be 90, 90 and 80. What did you get when you ran the program?

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

For char arrays you can use strcmp() which is defined in string.h to check if the two character arrays are the same or not. strcmp() returns 0 if the two are identical.

if( strcmp(str,"hello") == 0) cout<<"world";