Tumlee 42 Junior Poster in Training

What code do you have so far? You're supposed to give us what you have so far, and we'll be happy to help but, but we're not allowed to be doing your homework for you.

Tumlee 42 Junior Poster in Training

Until we see what the CALL_DATA struct or class looks like, we can't really know for sure.

Tumlee 42 Junior Poster in Training

You're already halfway there when it comes to understanding this line, then. For this code to make sense, src has to be a pointer to a pointer type, such as char**, and offset has to be a pointer type, such as char*.

What this particular line of code is doing is saying "Make the memory at the address pointed to by offset equal to the value at the address pointed to by *src (src itself being an address that points to that address), and then increment *src so it points somewhere else." It sounds like a mouthful, but that's how it works.

Tumlee 42 Junior Poster in Training

You're not accessing an array wrong, you're causing a stack overflow because Solve() keeps calling itself over and over again when the parameter is zero

Tumlee 42 Junior Poster in Training

When you push a char* into a vector, you're not adding the actual characters to the vector, but rather a memory address that points to the characters. What's probably happening in your case is that file.cFileName (a memory address) remains the same, so you keep pushing the same value over and over again into temp. However, the actual characters pointed to by file.cFileName keeps getting changed every time you call FindNextFile().

The way you're going about this is actually dangerous, because if file.cFileName ever had to change locations, you program would instantly crash the moment you tried to access to old memory. A better way to go about this is to have the type of temp be a vector of string rather than of a vector of char*.

vijayan121 commented: Yes. +14
Tumlee 42 Junior Poster in Training

Your equality comparisons makes so sense in circleIntersections(). On line 40, your condition is else if(quadraticRoots(h,k,r,x1,x2)<0). Why are you checking to see if the number of roots is less than zero? Because quadraticRoots() only ever returns values of 0, 1, and 2, this if statement is never true. You probably should be checking to see if it's equal to 1.

You make a similar mistake on line 44. else if(quadraticRoots(h,k,r,x1,x2)>0). This statement is asking if there is more than zero roots, which will hold true if quadraticRoots() returns one or two. Instead, you want to check if the returned value is 2, if you want the code to work correctly.

Tumlee 42 Junior Poster in Training

Or even putchar which makes even more sense.

How? putchar() only outputs a single character. If you're not allowed to use loops, you'll have to make ten calls to that in a row.

Tumlee 42 Junior Poster in Training

Assuming you're giving us all the information we need, there's a ton of ways to do this without using loops and cout. One could use standard C functions like puts() or printf(), for example.

 #include <cstdio>

 int main()
 {
     printf("**********");
     return 0;
 }
Tumlee 42 Junior Poster in Training

Your problem is in line 11.

void insert(int i, string elem, vector<string> st)

What you're doing here is a pass-by-value operation. This means that you're not actually passing your vector to the function, but rather just a copy of that vector. Your function modifies the copy, but the original vector remains untouched.

The fix is very simple --- turn it into a pass-by-reference operation by putting an ampersand after vector<string>.

void insert(int i, string elem, vector<string>& st)
Tumlee 42 Junior Poster in Training

You need to declare a variable that actually stores the position of the maximum. Right now, you're using c, which is equal to the number of values you have stored, so that's exactly the number it's gonna print out. If I were to rewrite this program, I would even go so far as to get rid of max altogether and just store the index of the maximum value (while keeping in mind that arrays in C start at 0, not 1)

#include <stdio.h>

int main()
{
    FILE *infile;
    float input[500];   // Allows the array to input a maximum of 500 values

    int datacount = 0;  //Number of values stored.
    int rover = 0;      //An iterator

    int maxposition = 0;    //Initialized to the first element.

//Terminate the program if the file can't be opened.
    if((infile = fopen("input.txt", "r")) == NULL)
    {
        printf("The file cannot be opened\n");
        return 1;   //Return 1 for failure.
    }

    printf("Values from inputed text file:\n");

//Read the data from input.txt and print it out to the screen.
    while(fscanf(infile, "%f", &input[datacount]) != EOF)
    {
        printf("%f\n", input[datacount]); // Displays the inputed values
        datacount++;
    }

//Rover through the data and find the maxiumum value.
    for(rover = 0; rover < datacount; rover++)
    {
        if(input[maxposition] < input[rover])
            maxposition = rover;
    }

//Print out the result and exit.
    printf("The max value is = %f and is at location %u\n", input[maxposition], maxposition+1);
    fclose(infile);

    return 0;
}

EDIT: Ugh, I really don't remember how to get syntax highlighting to work on this website anymore.

Tumlee 42 Junior Poster in Training

What are you trying to do with the variables int u and int c?
It looks like you're trying to count the number of elements with both with u, but every time you increment it, you also make c the same value.

In your for loop, you're setting c to u, thus making the loop terminate instantly. Because you initialize u to 1 when you declare it (and also in your for loop), you're actually leaving the first element of input unused. Give your variables more descriptive names and you'll be able to figure out the problem much easier.

Tumlee 42 Junior Poster in Training

Let's go through this problem by problem.

1) You got completely confused while naming your member variables. As pyTony said above, in student.h:

    int newid;
    string newname;

Should be changed to:

    int ID;
    string Name;

To finish fixing these naming conflicts, change Student::Student(int ID, string Name) to Student::Student(int newid, string newname) in student.cpp.

2) In main(), you are calling student.setStudentID("1234");. When you put quotes around something, you're turning it into a char*. This function is supposed to take an int. Remove the quotation marks on this line and it should work.

3) In Student::display(), some of your chevrons are backwards when using cout. Flip those around.

Tumlee 42 Junior Poster in Training

Attempting a compile got me some errors. On line 138, you have printPayroll( recordlist[] );. There is no need for these empty brackets unless you're declaring an array. Remove them and that error should be solved.

On line 164, I get the error that r has not been declared in this scope. On your compiler (which I'm assuming is old), you may not need to declare r as an int, but I suggest replacing r = 0 with int r = 0 just to be sure.

The function printPayroll() has a return type of vector<Records> but you have no return statement in that function. Since it's only printing out information, you probably meant for the return type to be void.

Tumlee 42 Junior Poster in Training

Wanna bet??? ;-)

Well, I can't think of a good reason to. Maybe if you wanted to take advantage of realloc() for some sort of insignificant speed boost.

Tumlee 42 Junior Poster in Training

malloc() is C's equivalent of C++'s new operator. It is usually defined in stdlib.h. It allocates memory for your program to use. It takes a size argument, which must be manually scaled depending on the size of whatever type of data you're trying to allocate. For example, to allocate 6 floats, you would have to use float* fptr = (float*)malloc(6 * sizeof(float));.

memset() is a function that sets all the bytes in a chunk of memory to a specific value. It takes three arguments:
1) A pointer to the first element you're going to change.
2) The value you're going to use to fill the chunk of memory.
3) The length of the chunk of memory, in bytes.

calloc() is like malloc(), except it takes two arguments (number of elements, and size of each element), and it automatically initializes all of the memory it allocates to zero.

i want to knw whr exactly i can use these.

You will never use malloc() or calloc() in C++. Ever. Just use new, it's simpler to use and you don't have to include any libraries to use it. As for memset(), you might end up using it, but I honestly can't think of a time where I've used it myself in a real program.

Tumlee 42 Junior Poster in Training

It's to make sure that the user of the class doesn't touch member data that he's not supposed to, or that when he does, it's in a fashion that is defined by the class (via a getter or setter function).

In my opinion, a "read only" keyword would have been a lot more useful (where the member data can only be written to by an object's own member function). To be quite honest, I haven't really found a practical use for private members myself, but that's probably because I write code I don't expect to be used by other people.

Tumlee 42 Junior Poster in Training

and you can use void main() there is no need of making it int.

Disregard this advice, Hitman.

then what is the problem???

This should explain why void main() is not only wrong, but it can also be dangerous: http://users.aber.ac.uk/auj/voidmain.cgi

Otherwise, the above code is more or less correct (I would have organized this entire program a bit differently).

Tumlee 42 Junior Poster in Training

Furthermore, it should be int main() not, void main(), and you should have return 0; at the end of your program.

Tumlee 42 Junior Poster in Training

One issue is here: &(*mPntr)
The other is here: &PntrFunc(&(*mPntr))

You can't get the location of *mPntr, because that's an expression, so your code doesn't make any sense. It would be like if you were to try to do this: int* ptr = &(a + b); It's obvious to see why --- the expression (a+b) doesn't have a permanent location, so using the ampersand on it serves no purpose. You can only get the location of an actual variable, such as theVar2.

Likewise, you can't get the location of a function call, that also doesn't make any sense. A function call also has no permanent location.

Tumlee 42 Junior Poster in Training

Use a new version of the compiler with the bug fixed

I suggest this one, because ideally a compiler shouldn't crash no matter what you feed it.

Tumlee 42 Junior Poster in Training

Java has the advantage that is has a virtual machine that runs under many Operating Systems. Like so, you can expect many things to work on as well on under OSx as you are under Linux and Windows (more or less). I don't really understand the point of C# though. I actually found it extremely annoying to use a program that was written in C#, as I had to do a lengthy install of some ".NET architecture" or whatever which doesn't even seem as self-contained as Java's JRE.

Every operating system I have ever come in contact with (except for DOS) has had enough memory protection to shut your program down if you try to write to memory that doesn't belong to your program, so it's not like you could end up writing a program that accidentally trashes your entire computer. There's nothing truly "dangerous" about pointers anymore (unless you consider your program terminating to be dangerous).

Tumlee 42 Junior Poster in Training

I would recommend getting rid of the (5) on the end of your declaration of Gifts, as that is usually used for initializing elements when you first create your vector. Do you already know how to use vectors? Online tutorials are everwhere, but I'll give you the run down. What you'll be doing is using the push_back() function to add elements to your vector.

For example, in your case, Gifts.push_back("Cake"); would add "Cake" as a gift idea. When you're printing out your gift ideas, you're obviously going to use a for loop, and Gifts.size() will return the number of elements in your vector. You access the elements the same way you would access the elements of an array.

Tumlee 42 Junior Poster in Training

You're probably creating a text file, but then you're just naming it like a PDF. Just changing the file extension doesn't change the data inside the file, it's still just text. That would be like calling your chicken a pig, slaughtering it, and expecting it to taste like pork.

I didn't even know it read pdf..

It doesn't. It can, however, read a text file renamed so it says ".PDF" at the end.

Tumlee 42 Junior Poster in Training

You first issue is on the lines that say cin >> people.fname >> people.lname; and cout << people.fname << people.lname;. The token people refers to the type of the structure, not its name, so this results in a syntax error. Since it's a member function, change these lines to cin >> fname >> lname; and cout << fname << lname;, respectively. The same sort of issue appears in birthday::output().

You forgot to actually make an object for the birthday and people structures. When you create a struct, you're only defining a type of object. You create an object in the same way that you make an int for float --- by declaring them as variables. Since you have two of them, you would add this to your main function:

people peoples[2];
birthday birthdays[2];

Again, in your loops, you're treating an struct like an actual object. You're also forgetting to put parenthesis in front of your function calls. Instead of people.input and birthday.input, use peoples[i].input() and birthdays[i].input().

In your second for loop, you're trying to treat functions of type void like they are of type string. This doesn't work and will result in a compiler error. Instead, you should seperate the output like so:

peoples[i].output();
cout << ": ";
birthdays[i].output();
cout << endl;

A few other things: In your output functions, you're forgetting to seperate the last names and the birthday numbers with spaces. Also, the program prompts the user on "month, date and year", but they are ordered …

Tumlee 42 Junior Poster in Training

You can use Adobe Flash to make an app.

How can he use Adobe Flash to make an iOS app, when iOS doesn't support Flash?

Apple pretty much has the whole App-making thing locked down to where you can't produce any iOS app without owning an Apple computer. From what I've heard, when Apple doesn't like an app they try to find something to reject it just to annoy the developers. Your best bet is to find a way around that, perhaps to virtualbox OSX so you can run xCode on a computer you want to use.

Tumlee 42 Junior Poster in Training

GBA programming seems like a hassle because you would have flash it to a cartradge, and deal with the GBA's various limitations.

I'll throw SDL's hat in the ring, as always: http://www.daniweb.com/software-development/cpp/threads/418882/game-design-classes-and-inheritance/1#post1786924

Tumlee 42 Junior Poster in Training

GBA programming seems like a hassle because you would have flash it to a cartradge, and deal with the GBA's various limitations.

I'll throw SDL's hat in the ring, as always: http://www.daniweb.com/software-development/cpp/threads/418882/game-design-classes-and-inheritance/1#post1786924

Tumlee 42 Junior Poster in Training

So would this be correct then?

Close, but remember that return statements immediately exit your funciton, so the way you wrote your code, tf would never be set unless value1 and value2 are equal. You want to swap the returns and the setting of tf.

Tumlee 42 Junior Poster in Training

As said above, you need to call fclose(ftdata);. To prevent future headaches, your third argument (count) should be set to 4 instead of 2 if you want to fully print "TEST".

Tumlee 42 Junior Poster in Training

SFML still has some maturing to do. The last time me and my friend tried to make something with it, it turned out it didn't even support certain computer architectures. In the meantime, I suggest using SDL, and it's extensions, SDL_mixer and SDL_image, to make a game. With the proper knowhow, you can make a full 2D game with sound, music, and graphics.

Tumlee 42 Junior Poster in Training

You are calculating the maximum value correctly, but you are forgetting to actually print it to the screen. The following should print your value.

cout << "The maximum value is" << Max(s,n) << endl;
Tumlee 42 Junior Poster in Training

In your declaration of mergesort() , you are giving it two arguments.

int mergesort(int,int);

But when you actually define the function, you gave it three.

int mergesort(int first,int last,int mid)

That is a mismatch, and it results in the linker error you ended up with. You fix this by changing either your declaration or the actual function so they both match.

Tumlee 42 Junior Poster in Training

This is definitely one issue:

printf("max = %d\n", max);
printf("min = %d\n", min);

max and min are not integers, they are functions that return integers, so these lines of code don't make any sense. I'm not even sure how you got this to compile, but your program is probably printing out the memory addresses of your min() and max() functions.

You're not even recording any of your grade's values anyway, so it will be impossible to know what the maximum and minimum grades are the way you wrote your code.
HINT: You need to recalculate the minimum and maximum values inside your loop.

Tumlee 42 Junior Poster in Training

The best thing to do is to show us the class or struct you're using as a box.

Tumlee 42 Junior Poster in Training

You don't need .NET to use <dirent.h> . It's part of the standard C library.

Tumlee 42 Junior Poster in Training

You are calling RemoveSpaces() before you call RemoveVowels() . Did you mean to put this the other way around?

Tumlee 42 Junior Poster in Training

The header you're looking for is <dirent.h> , which allows you to use the opendir() function. That function opens a specific folder and allows you to iterate through all the files in that folder and view their names and sizes. If you look up tutorials on using that library, you'll find what you need.

Tumlee 42 Junior Poster in Training

If the algorithm was "simple" it probably wouldn't compress very well. If it helps you understand better, many compression algorithms actually can end up making a chunk of data larger if it's not suited for the task (notice how sound files don't compress very well at all with ZIP compression).

Tumlee 42 Junior Poster in Training

Are you trying to just turn the vowels into spaces? If so, your code works perfectly on my end.

Tumlee 42 Junior Poster in Training

No, the code is not correct at all.

It's not supposed to be <iostream.h> , it's just supposed to be <iostream> .

You shouldn't be using <conio.h> at all, because that just allows you to use old DOS-isms that can be done in a more portable way.

You're not supposed to use void main() , you are supposed to use int main() . Furthermore, you are supposed to have return 0; at the end of your program, not the ancient and deprecated getch(); .

The line ch=a; will immediately cause a compiler error because ch is a static array, and that line of code is an attempt to change its location (which is illegal). You don't even need an array in this case anyway. Actually, you don't even need the variable a .

I'm pretty sure you need to have using namespace std; before the main() if you want to be able to use cout .

If you want to print the a character based on the ASCII value with cout , the following is sufficient:

#include <iostream>

using namespace std;

int main()
{
    char ct = 10;    //Replace the number 10 with whatever the ASCII value is.
    cout << ct;

    return 0;
}
Tumlee 42 Junior Poster in Training

There is no such thing as an EXE that will run under all machines. Turbo C makes DOS programs. DOS compatibility has been whittling away on Windows (and for good reason). There is no guarantee that your program will work perfectly under any operating system newer than Windows 98, unless you want to force the user to run your program through a virtual machine like DOSBox.

Tumlee 42 Junior Poster in Training

Doesn't the new C++ standard allow you to define the size of your enum type?

Tumlee 42 Junior Poster in Training

There is no difference unless you're using a class that detects the type of the data and does something different with it depending on that type. For code clarity, you should use 0 when talking about a number, '\0' when talking about a string-terminator, and NULL when talking about a pointer.

Tumlee 42 Junior Poster in Training

I would recommend enum in this case because that's exactly what they're there for.

Tumlee 42 Junior Poster in Training

He's expecting the compiler it to align all instances of this structure to 4-byte boundaries via padding. I'm not entirely sure if this should actually change the value returned by sizeof().

Tumlee 42 Junior Poster in Training

"Just make an empty method" I would need a little help. How to do it ?
(I know it sounds stupid but I haven't touched c++ in 10 years...)

You would just make a function put nothing in the brackets except for a return; statement in this case. If the function was non-void you'd probably want it to return an actual value. The following should probably work:

void CheckFileNames::RecordAsset(const MaxSDK::AssetManagement::AssetUser& asset)
{
    return;
}
Tumlee 42 Junior Poster in Training

When I make an SDL program (compiled under Windows 7), it doesn't require any such DLL even under Windows XP. Ichigo, would you happen to be building your game under Microsoft Visual C++? I know that even terminal programs made with that compiler require that DLL for some reason --- even release builds.

Tumlee 42 Junior Poster in Training

If you want to create a program in C or C++ with graphics, you should first switch to a modern IDE (like Code::Blocks or Visual C++). From there, you should learn how to a library like OpenGL, SDL, DirectX, or something similar.

Tumlee 42 Junior Poster in Training

Most environment/compilers require a newline at the end of your file, otherwise it won't compile. Some will even go as far as to add them in for you. Try adding it in and see if that resolves the problem.

Tumlee 42 Junior Poster in Training

C++ and C are just as capable as any other language when it comes to using the internet, networking, etc. There are all sorts of libraries out there to do that sort of thing. Even C can have, for example, a game that uses UDP that can be used for online play.

However! C++ and C are not designed for making webpages, or browser-based games.