1,608 Posted Topics

Member Avatar for Slavrix

[code] char rowComp = 0, colComp = 0; while(colComp <= COL) { while(rowComp <= ROW) [/code] Without my ESP hat on I can't tell what the error messages are that you are getting. But I can tell you that the above should probably be changed to: [code] int rowComp = …

Member Avatar for Slavrix
0
135
Member Avatar for Escom

A simple empty main() is always a good place to start! Since this isn't a math or physics forum, by t square matrix do you mean a matrix with an evern number of rows and columns? If so, and if you use notation similar to (0,0) to denote any given …

Member Avatar for Lerner
0
108
Member Avatar for Shad0wHawk

The string class overloads the [] operator so individual characters can be accessed just like with a char array. the c_str() method will return a const char* to the char array embedded within the string object if you want to change the string into a char []. You could do …

Member Avatar for Shad0wHawk
0
350
Member Avatar for yuzhang

Two common places for a programmer to use the copy constructor are: MyClass one; //uses default constructor MyClass two(one); //uses copy constructor MyClass three = one; //uses copy constructor The compiler will also use the copy costructor and you aren't aware of it, unless you are intimately familiar with how …

Member Avatar for Narue
0
122
Member Avatar for pulse0

>>where do I put "string::c_str()" in my code? Whereever you need to uncover the C style string hidden in a STL style string object, like when you want to use atoi() to convert an STL style string to an int, etc. Also, using the return value of eof() to control …

Member Avatar for John A
0
245
Member Avatar for Thinka

>>print the numbers in order? First you need to specify what order you are going to print them in and then where you are going to print them. If you want to print them to file in ascending value then you will need to store them all in a container …

Member Avatar for Thinka
0
290
Member Avatar for shamma

I think this will work. Let's change it up a bit. Say I put some numbers in a paper bag, gave you the paper bag and said take the numbers and tell me what the biggest and smallest number in the bag was. One way you could do it is …

Member Avatar for Lerner
0
78
Member Avatar for bigben09

You need to store each set of inputs in some sort of container, sort the contents of the container, then print out the sorted values. There are several containers that could be used, though for beginners arrays seem to be the most common. There are several sorting protocols that could …

Member Avatar for Lerner
0
93
Member Avatar for Rob111

I have no idea what the Lee algorhithm is, or isn't. However, given your description and your post, I presume you could do something like this. The pattern presented can be considered as a series of lines on top and a series of lines on bottom where Each line has …

Member Avatar for Rob111
0
277
Member Avatar for -_00_-

Who knows how much, if anything this will help, but the user can select a value for a variable called choice which can range from 1-3 and is used as an index in an array that has three elements which can have indexe ranging from 0-2, so when user selects …

Member Avatar for -_00_-
1
120
Member Avatar for Mac.Z

three calls to getline() with the first two using : as delimeter and third using newline. Then convert each string obtained into numerical value using sprintf() or strtol() or atoi() or stringstream, etc.

Member Avatar for Mac.Z
0
319
Member Avatar for diegojoven

1) use code tags when posting code to the board 2) intialize cnt to 0 every time count() is called 3) it isn't polite to highjack someone elses thread. Though there is some similarity between your problem and the original problem presented, it's not the same and a new thread …

Member Avatar for WaltP
0
103
Member Avatar for sundarN

I'd use serial calls to getline to parse the file. #1 read information up to = and ignore input #2 read information up to : and save #3 read information up to : and save compare #2 and #3 and do whatever #4 read informtation up to newline and ignore …

Member Avatar for Lerner
0
62
Member Avatar for rapperhuj

Of course the other way is to use STL string objects and just use the overloaded logic operators built into the class, but I don't think that's quite what your question meant.

Member Avatar for wise_monkey
0
119
Member Avatar for teteret

the baseline behavior of fgets() is that it will read in the newline char in addition to the alphanumeric char and other whitespace char if there's enough room in the array. So I here's what I would try. Declare the target string to include two more than the max number …

Member Avatar for Lerner
0
1K
Member Avatar for ganesh_c

I'd try declaring the array using pointer to pointer syntax within the declaration of the struct. Then within the constructor I'd use dynamic memory to declare the memory. The dimensions could be hard coded or "user supplied". The destructor would probably release the memory declared. Assuming you are using C++ …

Member Avatar for Lerner
0
50
Member Avatar for civil1

You could use the division and the modulo operators in sequence to generate indivual digits which could be used to increment counters in an an array of ints and then print out the array values with the associated indexes when done. But that's just a guess as to what algorhythm …

Member Avatar for Lerner
0
82
Member Avatar for shmay

Look up C output format specifiers. The number will be stored to whatever degree of precision that is allotted to type double, but the degree of precision can be dictated on displaying the value.

Member Avatar for Rashakil Fol
0
177
Member Avatar for kendell

Please don't start a second thread for the same problems discussed in a prior thread. [code] while (getline(inFile, list )) line.substr(0, 6) [/code] Where/how is the return value of substr() stored in an array of strings? If you read the file using this code then the array of strings representing …

Member Avatar for Lerner
0
95
Member Avatar for kendell

declare an array (or vector) of strings to hold the original strings and a second array (or vector) to hold the 6 char strings. Use a loop to read the first 6 char of the originalString[i] into sixCharString[i] one at a time accesses each char using the 2 dimensional [][] …

Member Avatar for Lerner
0
97
Member Avatar for raj157

If argc equals 5 then the last valid index for argv is 4, not 5, since array indexing is zero based. That also means that argc - 1 should probably be argc - 2. Typically you would just declare the ifstream once by declaring it outside of the for loop. …

Member Avatar for vijayan121
0
314
Member Avatar for raj157

Pointers can be tricky until you've used them a while. Basically a pointer is an address of something. There are three ways you can get the address of something: You can use 1) pointers: int * a; //means the address of an int variable is held in a 2) the …

Member Avatar for raj157
0
106
Member Avatar for Riazansar

>>its not giving any error Wow. What compiler are you using? I'm surprised it compiles at all. You use a variable in workSieve that isn't declared. Remember that b isn't the same as B in C/C++.

Member Avatar for Riazansar
0
149
Member Avatar for naya22

Use variables. int numberOfHoursUsed; int baseHours; double excessFee; double baseFee; double totalFee; double overchargeRate; int overchargeTime; baseHours is given for a given program basFee is given for a given program overchargeRate is given for a given program overchargeTime is numberOfHoursUsed minus baseHours excessFee = overchargRate times overchargeTime totalfee = baseFee …

Member Avatar for naya22
0
116
Member Avatar for student86

Welcome to Daniweb! I'm having trouble telling where option 1 and 2 separate and whether there is a third option. Your description however sounds pretty good. Some folks here would prefer to see you use something like sprintf() or a stringstream to convert strings to numerical values, but atox() family …

Member Avatar for vijayan121
0
92
Member Avatar for jerryseinfeld

I'd read in the file one field at a time storing the information in a struct that I'd then store in a container. As I was reading in the first field I'd check it against the current longest name. When I'd read in the entire file the longest name would …

Member Avatar for jerryseinfeld
0
125
Member Avatar for l-o-s-t

>>when I try to manipulate the first node in the list, nothing happens to the first node in the list back main function, so it seems to be changing that locally, however main doesn't seem to acknowledge these changes ... could anyone please tell me how can you change the …

Member Avatar for l-o-s-t
0
130
Member Avatar for maverick786

[code] //set loop pointer to start of loop loopPtr = listPtr; //look at all nodes in list while (loopPtr != NULL) { //if you find it if(loopPtr-> item == Item) //you can stop return true; else //otherwise look at next node in list loopPtr = loopPtr->next; } //if you get …

Member Avatar for Lerner
0
79
Member Avatar for MarzenaM

The basis for a solution to this project is given in the parenthesis at the end of the problem statement. If you use the modulo operator on two ints like this: a % b then the return value is the remainder of a divided by b. So if a were …

Member Avatar for MarzenaM
0
107
Member Avatar for adnichols

Welcome to Daniweb C/C++. Please read the announcement at the top of the page regarding use of BB tags or the watermark in the Message box regarding the use of code tags specifically. Using these tags will keep the formatting of your code as you post it. If you don't …

Member Avatar for adnichols
0
134
Member Avatar for satish.paluvai

In my experience it means the linker isn't able to find a function/variable in any of the header files included. Often it means the necessary header file isn't included or the function/variable isn't available in the files included.

Member Avatar for vijayan121
0
82
Member Avatar for wujianwei

Read the input into a string, not a numerical variable. Then validate the string. Once validated convert the string into a numerical variable.

Member Avatar for WaltP
0
98
Member Avatar for teh_man

[code] char board[7][7] ; for(i = 0; i < 7; ++i) for(j = 0; j < 7; ++j) board[i][j] = '*'; //fill board with *s turn = player1 = X; row = 2; //using choices 0-6; col = 5; //using choices 0-6; board[row][col] = 'X'; //display board for(i = 0; …

Member Avatar for Lerner
0
134
Member Avatar for jerryseinfeld

In the OPs recent posts he consistently does this: [code] for(i=0;i<=5;i++);{ for(j=0;j<=5;j++);{ [/code] Unfortunately the semicolon stops the loop before the opening braces become evaluated so they are worthless. If you want to do something in the body of the loop don't have semicolon right after the control statement. It …

Member Avatar for Lerner
0
192
Member Avatar for RaCheer

A map would be one way to do it. If you don't know about maps, then using a sequence of arrays can do it, too. After your initial array is sorted it will look like this: A => 33566 Now you could set up an array of unique numbers in …

Member Avatar for Lerner
0
107
Member Avatar for zaacze

Target is declared as a string but you treat it as a single char in the call to scanf() and then you treat the single char as a string in strcmp. You similarly type mismatch single char for strings in other scanf() calls, too. What's the feof thingamabob? You need …

Member Avatar for WaltP
0
113
Member Avatar for rowly

push_string() could use a for loop like you have in main() in push_string(). You are basing your stack on a list and adding each new node to the front of the list, which is fine. However, the very first node in the list has to be somewhat different than any …

Member Avatar for rowly
0
1K
Member Avatar for afr02hrs

Is this more what you're trying to do [code] //read each char of Line while (Index <= Length(Line)) { //if current char is not a space if (Line[Index] != ' ')//; { //write current char to screen WriteChar(Line[Index]); Index = Index + 1; } else //if current char is a …

Member Avatar for Lerner
0
347
Member Avatar for jobra

Given the use of the STL string class and the iostream objects I'd say the program is using the C++ language and the C language time header file since templates and iostream objects cannot be used in C. I'm not sure the STL string header includes the iostream header, though …

Member Avatar for WaltP
0
120
Member Avatar for rdsii64

>> balance -= ( monthlyInt + principalPaid ) I'd like you for my banker if you are going to deduct my monthly interest payment from my balance in addition to primical payment!

Member Avatar for thekashyap
0
130
Member Avatar for guy40az

A brief summary of the usefulness of pointers. 1) They can let you use the information in an entire 5kb array (or any other memory hog) in another function having to copy/send only 4 bytes instead of the entire 5kb (or whatever). 2) They allow you to use the (usually) …

Member Avatar for Lerner
0
120
Member Avatar for bigben09

There is no easy way to limit output to a given number of decimal places in C/C++ that I've seen. After wrangling through a rather lengthy discussion previously, I'd store the whole number part of the given number as an int through casting, then multiply the given number by 100, …

Member Avatar for tayster
0
251
Member Avatar for Duki

You may need to use preposser commands like : #include <string> using namespace std; Line 11 : You're sending a literal string to itsVowel, not a string entered by the user. In fact there is no way for a user to enter a string in this program. Line 22: The …

Member Avatar for Duki
0
245
Member Avatar for Jasy
Re: C++

The logic of your program seems reasonable but your use of variables seems weak, for example where did datafile and ch come from; and you need to look up the declaration of the istream open() method--is it supposed to be myinput.open(sesame?) or is it something else you're trying to open, …

Member Avatar for Lerner
0
122
Member Avatar for RisTar

You're doing a shallow copy of array to array2. When you free the memory for array you also loose the memory you were pointing to in array2. Do a deep copy of array to array2 by assigning independent memory to array2 using malloc() like you did for array, and then …

Member Avatar for RisTar
0
113
Member Avatar for bobcats

Here's another approach that might work. Use a list to hold the words and their frequency since you don't know how many words you will have and you are using C so STL vectors won't help. Each node in the list would have a char * for the word and …

Member Avatar for bobcats
0
353
Member Avatar for Tauren
Re: c++

Yes. C++ is the language and Visual C++ is an Integrated Development Environment that contains all the software you need to write programs with the C++ language. You can use other software to write programs using the C++ language if you want, though many people like, or are required to …

Member Avatar for John A
0
126
Member Avatar for mrjoli021

You'll also need a variable to hold the current guess, a protocol to access each element in the char array and determine if it is equal to the current guess and a variable to keep track of how many times the current char is found in the array and a …

Member Avatar for mrjoli021
0
77
Member Avatar for JadedTortoise

[code] if (B == 0) { C = 1; else if (prime % primes[b] == 0) B = 0; } [/code] Remove the { and the } or do this [code] if (B == 0) { C = 1; } else if (prime % primes[b] == 0){ B = 0; …

Member Avatar for WaltP
0
117
Member Avatar for dballers
Re: ask

Welcome to the DaniWeb! You should know it's discouraged to do homework for you. However, demonstrate your efforts and many people will help guide you by offering corrections, comments, etc. For any project it's important to understand the problem. So, for example do you know what the sympbols ^ and …

Member Avatar for dballers
0
106

The End.