419 Posted Topics

Member Avatar for soffie

First off you want to call srand() before you use rand() otherwise you will always get the same value for the first random. Also you can take a look at a snippet I made for allocating memory in a 2 dimensional array. It uses user input and it expands on …

Member Avatar for soffie
0
2K
Member Avatar for sfuo

This program asks for integers from the user and stores them into a multidimensional array that adjusts its size.

Member Avatar for VernonDozier
0
1K
Member Avatar for kingstrider

First off this is the C++ forum and not the C one but I will show you a way of doing it in C++ since I don't know what headers C++ has and C doesn't. [CODE]#include <iostream> using namespace std; int main() { int input, output = 0; cout << …

Member Avatar for sfuo
0
88
Member Avatar for HolyVenom

What do you mean remove? The way that stuff works is on the next draw you can just not show it but once something is drawn it is there for that frame.

Member Avatar for sfuo
0
32
Member Avatar for hezfast2

You are recalling the function so it will never run the if statement I commented. [CODE]for(int x = 0; x < 8; x++) { if(checkPosition(r + moveRow[x], c + moveCol[x], size)) { count++; movePosition(r + moveRow[x], c + moveCol[x], size, count); if(count < (size * size)) //this never runs { …

Member Avatar for hezfast2
0
106
Member Avatar for monita

This is the C++ forum and you don't as people to do your assignments or whatever that is without showing some input other than what you want your output to be.

Member Avatar for Tom Gunn
-5
68
Member Avatar for sfuo

I am making a rubix cube game in OpenGL and I have run into a problem with rotations. When doing multiple rotations (x, y, z) the axis gets rotated as well (ie when doing an x-axis rotation of 90 or 270 deg the y-axis becomes the z-axis and z-axis becomes …

Member Avatar for mrnutty
0
144
Member Avatar for racumin

I could see there being a problem if you made xxx a pointer to getText() and some how getText() got destroyed then it would be pointing to an object that no longer exists. The example you posted is assigning xxx to the value your getText() function returns. So xxx is …

Member Avatar for mrnutty
0
133
Member Avatar for Ponomous

[ICODE]infile >> name[/ICODE] only takes in the first name not both first and last because like cin, your infile will stop at a '\n' new line character or a space character.

Member Avatar for Ponomous
0
318
Member Avatar for poopynoob

A char is for a single character meaning if you type in "Hello" it will only save the 'H' to the char variable. You can make a char array [ICODE]char myarray[size];[/ICODE] This will be able to hold as many characters in it as you have "size". Or you can include …

Member Avatar for poopynoob
0
154
Member Avatar for ross42111

I don't know why you are putting two numbers into your month function to return one number. Are you trying to take the number month and convert it into a word? For example: 1 = January 2 = Febuary 3 = March... If so try this. [CODE] string monthConverter(int num) …

Member Avatar for sfuo
0
104
Member Avatar for sfuo

Hi, I was wondering if anyone could help me figure out how to see who is connected to you when you are hosting a game on a specific port via c++. I know you can use netstat in cmd prompt and it shows a bunch of info of who you …

Member Avatar for lashatt2
0
135
Member Avatar for infern0

Why can't you just use char for sign like you are and if that is x then stop and for input and total I would just use integers. [CODE]#include <iostream> using namespace std; int main() { char sign; bool end = false; int total = 0, input; cout << "Current …

Member Avatar for Phil++
0
89
Member Avatar for mcap61

Your name_first and name_last variables are char arrays. And I find it funny how your teacher would show you how to make structures before arrays but I guess I learned in a different order. The best thing to use would be a vector container but using an array would work …

Member Avatar for mcap61
0
142
Member Avatar for Trini89

Your prototype functions need to match your full functions below main() unless you are trying to overload the functions (I don't think you are). Also the timeoffall value that you get out of the function stays in the function because you aren't passing a variable by reference or making it …

Member Avatar for Trini89
0
123
Member Avatar for wyett

Another way to write this would be: [CODE]class Fraction { int numerator; int denominator; char sign; public: Fraction(int _num = 0, int _den = 1, char _sign = 'p'); }; Fraction::Fraction(int _num, int _den, char _sign) { numerator = _num; denominator = _den; sign = _sign; }[/CODE] [CODE]Fraction(int _num = …

Member Avatar for wyett
0
89
Member Avatar for amirun

Why don't you try asking nicely. I looked at all 3 of your posts on this forum and they are all super demanding as if you are expecting people to do work for you as if you are some boss.

Member Avatar for rdrast
0
106
Member Avatar for osgiedeprof

I know a way of doing this and I'll post an example for you but what kind of data do you want? Do you want it to be an array of cstrings? List[length][numberofentries] or List[row][col]

Member Avatar for sfuo
0
96
Member Avatar for restrictment

The spacing between A and B is changed because it was huge but other than that its the same. [CODE]#include <iostream> using namespace std; int main() { for( int i = 1; i <= 10; i++ ) { for( int c = i; c >= 1; c-- ) cout << …

Member Avatar for restrictment
0
170
Member Avatar for jamdownian

As a general note if you want people to read your code learn to format it in a clean way. Having bad indents and no white space and cramming everything onto one line by throwing in semi-colons makes it just as hard to read if you don't use code tags …

Member Avatar for jamdownian
0
137
Member Avatar for ninreznorgirl2
Member Avatar for Lerner
0
212
Member Avatar for Duncans Ghola

On line 30 you have if( denom = 0 ) and it should be if( denom == 0 ) it crashes because it makes denom equal to zero and it is doing what you are trying to prevent.

Member Avatar for Grn Xtrm
1
253
Member Avatar for tomtetlaw

You can use the substr() function to copy part of a string to another string. I find this website really good for stuff like this [URL="http://www.cplusplus.com/reference/string/string/substr/"]here[/URL]. That is a link to the substr() reference but there is a whole lot of examples for other class functions. Added an example program …

Member Avatar for sfuo
0
103
Member Avatar for sebassn

Does it have to have the nested if-else statements or can you just use a vector to store all the ints in and then sort the vector?

Member Avatar for VernonDozier
0
119
Member Avatar for ross42111

You pretty much have it as while 'Q' is false. 'Q' is 'Q' not true or false. You want it as while valid is false and valid becomes true when a valid season is picked.

Member Avatar for WaltP
0
107
Member Avatar for ENCHTERP
Member Avatar for Frederick2

I use devC++ and if I want to use the <cstring> library I do not need to use <iostream> or <iostream.h>. And I have never used MFC so I wouldn't know but since I don't use it you do not need to include it.

Member Avatar for Frederick2
0
301
Member Avatar for uzimuzi

For displaying arrays you do not just call the array its self you have to make a for() loop to output. [CODE]for(int i = 0; i < 8; i++) { cout << arr[i]; }[/CODE]

Member Avatar for uzimuzi
-1
331
Member Avatar for James19142
Member Avatar for James19142
-1
346
Member Avatar for nated

I copied exactly what you have and I didn't get any errors. What compiler do you use?

Member Avatar for sfuo
0
138
Member Avatar for rhoit

Take a look at [URL="http://www.daniweb.com/forums/thread224343.html"]this thread[/URL]. I think this is what you are looking for.

Member Avatar for mrnutty
0
294
Member Avatar for Darth Vader
Member Avatar for eplymale3043

When I think of Mad Libs I think of a preset sentence with blanks in it. You are asked to fill in the blanks with the type of word needed and then you read out the sentence with your words. For this I would make up like 5 sentences and …

Member Avatar for sfuo
0
506
Member Avatar for NinjaLink

[CODE] #include <time.h> #include <iostream> srand(time(NULL)); char randChar = rand()%(90-65)+65; int makeLower = rand()%2; if( makeLower == 0 ) { randChar += 'a'-'A'; }[/CODE] This generates a capital char then converts it to a lowercase if makeLower is equal to 0.

Member Avatar for VernonDozier
0
115
Member Avatar for cbreeze

Do you have to use the class word for word? Or can you change some return types and parameters.

Member Avatar for VernonDozier
0
201
Member Avatar for tomtetlaw

I think its just checking from a list of options and if it is not there it throws you the error that it does not have a spawn function.

Member Avatar for tomtetlaw
0
72
Member Avatar for rajeevns

So post some sample code of what you have so far. We don't hand out free code for assignments.

Member Avatar for Laiq Ahmed
0
85
Member Avatar for xxunknown321

The function mazeTraverse() is pretty much this whole program. It checks to see if the position in the maze that is it at is a space and then if it is it runs its self 4 items (up one spot, down one, left one, right one) and doing the same …

Member Avatar for Lerner
0
202
Member Avatar for lancevo3

Is this where it says the error is? Or can you post all your code if it isn't too long.

Member Avatar for sfuo
0
785
Member Avatar for Se7Olutionyg

Why are you calling the prototype with no parameters? This would be the problem that I see.

Member Avatar for sfuo
0
129
Member Avatar for infern0

You have one of your cin's with operators going the wrong way << you want it >> like the rest of them. Also, you have it so it compares the input to a variable that are not assigned. Either assign Apples, Oranges, Pears or change your if() statements to [CODE] …

Member Avatar for sfuo
0
91
Member Avatar for joshk6656

I'm going to assume scanf() is like cin in the way that it cannot take in spaces. One way to use cin to take in spaces is to use getline(cin, variable). Then use cin.ignore() if you run into a problem with the '\n' character skipping inputs afterward.

Member Avatar for joshk6656
0
147
Member Avatar for chingkoysilog

Well we cant give you the solution 100%. I know a bit about winsock for windows and I could help you make a client/server for it but you have to ask questions and I will help answer them.

Member Avatar for sfuo
0
513
Member Avatar for Asif_NSU

Last post was March 15th, 2006. In the before posting thread it says don't post on dead threads.

Member Avatar for devmakwana
1
2K
Member Avatar for usagi713
Member Avatar for sfuo
0
97
Member Avatar for gretty

Your return value is the type of function that you declared. For example if you make int sum(int x, int y) { return x+y; } this function returns an integer. Your return value is a set and that is a class type you defined. It looks like you are just …

Member Avatar for StuXYZ
0
94
Member Avatar for sohaib770

Is this what you are trying to do? This is a very general example [CODE]#include <iostream> #include <string> using namespace std; string myReturn( string in ) { return in; } int myReturn( int in ) { return in; } int main() { string strIn = "20"; int intIn = 20; …

Member Avatar for Lerner
0
71
Member Avatar for shahanakazi

I used the nested for() loops for it and I got it to work fine for any input. This is just the function: [CODE]void drawShape(int nrP) { for(int r = 0; r < nrP; r++) { for(int c = 0; c < (nrP*2-1); c++) { if( r == nrP-1 && …

Member Avatar for Barefootsanders
0
160
Member Avatar for thisisanfield.1

Give this a try. [CODE]ifstream infile; ofstream outfile; int size = 1; infile.open("input.txt"); struct Student * data; struct Student * temp; data = new struct Student[size]; int i = 0; while( !infile.eof() ) { infile >> data[i].First >> data[i].Last >> data[i].Score1 >> data[i].Score2 >> data[i].Score3 >> data[i].Score4 >> data[i].Score5 >> …

Member Avatar for thisisanfield.1
0
141
Member Avatar for Doughnuts

The End.