C++ :: How To Make Specific Character Show Up Specific Amount Of Times

Mar 5, 2013

How do I make a specific character show up a specific amount of times?

Like I am generating a random number then I need to make "|" show up that many times on the screen.

View 1 Replies


ADVERTISEMENT

C++ :: Determine Number Of Times Change Each Specific Character In String To Make It Palindrome

Feb 19, 2015

I'm trying to determine the number of times I have to change each specific character in a string to make it a palindrome. You can only change a character one at a time from the end.

Example: "abc" -> "abb" -> "aba" should print 2. "aba" will print 0 because it's already a palindrome. "abcd" -> "abcc" -> "abcb" -> "abca" -> "abba" will print 4 because it took 4 changes to make a palindrome.

I'm not too sure how to approach this - I figured out the case where if it's a palindrome (if reversed string is the same) then it'll print out a 0.

int main() {
int number;
cin >> number; //expecting a number for first line user input
for (int i = 0; i < number; i++) {
string str;

[Code] ....

View 1 Replies View Related

C/C++ :: Counting Specific Amount Of Times A Number Shows Up

Apr 11, 2015

Ok, so I am writing this program with 10 different functions, and one of those functions needs to count how many times 0 appears in a text file. I've done this before, but I am so stumped right now. Should I get the numbers from the 2d array I have, or should I just use the text file here? Here is what I have right now:

int toursMissed(int scores[][COLS]){
int counter;
for(counter=0;counter<=96;counter++){
if(scores==0){
counter++;
return counter;
}
}

View 7 Replies View Related

C++ :: How To Read Input Of Arbitrary Amount Of Numbers Instead Of Specific Amount

Feb 25, 2015

I'm trying to make a program that allows the user to input an arbitrary amount of numbers and finding the largest of all the inputs but I keep having problems with the output.

javascript:tx('
#include <iostream>
using namespace std;
//******************************************
//CLASS COMPARATOR
//******************************************

class comparator {
public:
comparator();

[Code] .....

And regardless of what numbers I enter, I always get the output of 10. Also I got the EOF idea from my textbook so if there is a better way of doing this I'd like to hear it. I don't know any clear ways that looks nice to end the while loop when the user doesn't have any more numbers to enter.

View 3 Replies View Related

C :: Read Specific Amount Of Data From File Until Terminating Set Is Reached

Jul 23, 2014

I wrote a code to read a specific amount of data from file until terminating set is reached. however the code does what its supposed to correctly until it reaches the 5th loop it justs stops responding. I've checked the reading file and all elements are correct in the file.

Code:
int main(void){
FILE *file1;
FILE *file2;
FILE *file3;

struct t test1;
struct t test2;

[Code] ....

Screenshot of program crashing:

Screenshot of reading file:

View 11 Replies View Related

C++ :: How To Search For A Specific Character In A String

Feb 4, 2015

i'm doing a validation exercise program. Just a question, how do i search an inputted string for a certain character?

For example:

Hello.World

I wanna determine and find out the where the '.' sign is.

I'm doing an if-else conditions, i need to determine where the character is located and make sure it doesn't repeat.

View 4 Replies View Related

C++ :: Bezier Curve - How To Extract Control Points From A Specific Character

Jun 12, 2013

I need to know how can i extract control points from a specific character. (this case is it possible?). So, more specifically, i have a specific character, let 'a' this character. So what i need, is how to extract control points from this character in order to draw it as a bezier curve.

View 3 Replies View Related

C# :: Make User Choose A Specific Path?

May 24, 2014

I am working on a program in C# that should make a user choose a specific path for the program to work.

The path they are choosing is a path for a game and from that selected path I use coding to load pictures from to the program.

Anyhow

I am able to make the user choose a path and save the selected path in a xml file.

But the user can select ANY path.

How could I do to make the user choose a specific path that I want them to choose?

View 13 Replies View Related

Visual C++ :: Letting User Enter A Character On Specific Line And Place?

Aug 8, 2014

How can I create in my C++ program so a user can paste a text and then choose a character on specific line and place?. The above thing isn't that important. I just want to place a character on a specific line and place.

I mean something like this:

Enter a character:

You choosed " / "

On which line do want the character?

You choosed "Line 1 and 2"

Where do you want the the to appear on the line? (left or right)

You choose left.

Results:

Line 1. / hello

Line 2. / hello

View 8 Replies View Related

C :: Read Text From A File And Show What Words Occur How Many Times

Apr 21, 2013

I'm trying to make program that will read text from a file and show what words occur how many times. I'm trying to make it so that if a new string comes, it saves it into wlist[], and counts 1 to wcount[]. If the same word is there, it will just add 1 to wcount[]. The program will end when it gets to the end of a file.

I don't know the reason, but I can't get strcmp and strcpy to work. I had to put a pointer in curword, just to make it compile.

Code:
#include <stdio.h>
#include <string.h>
#define LIST_MAX 100
#define WORD_MAX 20
int main(){

[Code] ....

View 6 Replies View Related

C/C++ :: Frequency Distribution - Finds All Numbers In Array That Show Up Exactly 5 Times

Oct 9, 2014

Create a program that finds all numbers in an array that show up exactly 5 times. I am trying to solve this issue by making a frequency distribution via two loops and two arrays, but I am having trouble getting my loop to not recount a number it has already counted.

For example, if you enter ten 1's into the "entered Numbers" array I want it to store a count of 10 in frequencyarray[1]. Instead it is storing

frequencyarray[0]10
frequencyarray[1]9
frequencyarray[2]8
etc...

#include <iostream>
using namespace std;
void enternumber(long[], int);
int main() {
int size;
int numbers5=0;

[Code] .....

View 14 Replies View Related

C++ :: TXT File - How To Get Each Specific Value And Add Them All Together

Oct 10, 2013

so I wrote this code in class today and I'm almost done but I need to come up with some sort of equation to add up all the total values. The problem is I am reading data off a txt file so it's all being read as one thing. I don't know how to get each specific value and add them all together. This is my code so far.

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;

[Code] .....

here's what's inside the input file

Chisel 50 9.99
Hammer 30 15.99
Nails 2000 0.99
Bolts 200 2.99
Nuts 300 1.99
Soap 55 1.89

I end up multiplying the amount by the price to get the total value as shown in the code above. Now I just don't know how to add the total value of each item to get the total overall value. Also I haven't used invTotal because I want that to be the overall total.

View 1 Replies View Related

C++ :: Returning A Specific Value?

Jun 8, 2014

How do I return a specific value from a function in order for me to cout it in my int main?

In this case i have solved for a value sigma1 in my function but i want to use the value of sigma1 in my int main also and in other places so how would i do that?

#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdlib>

[Code].....

View 5 Replies View Related

C# :: How To Get AI To Look For Specific Buttons

May 5, 2014

Basically I am creating a game and I need the ai to look for specific buttons. At the moment this is the code I have, and what it does is it makes the ai look for any random button that has't already been clicked.

Code:

private Button look_for_spaces() {
Console.WriteLine("Looking for spaces");
Button b = null;
foreach (Control c in Controls) {
b = c as Button; // performs a cast

[Code] .....

Now what I'm trying to do is make the ai go through 4 searches in steps instead of looking for any button. I want it first to look for buttons 1, 2 and 3, if there's a space in any then it will be clicked but if all of them are already clicked it will look for spaces in buttons 4, 5 and 6 and so on if that makes sense. But i'm not too sure how I would do it.

View 3 Replies View Related

C :: Scan Value For Specific Data

Dec 13, 2014

I created a program that will create a file and print a list on it. Here is the code for my program:

Code:
int controlvalue(void) {FILE *controlvalue;
controlvalue = fopen("something.txt", "a+");
/* Series of fprintfs */
fclose (controlvalue);
return 1;}

Here is an example list created by my program:

Code:
[Gifts]Candy=45
Chocolate=32
Toy=128
Robot=754
Doll=1492
Star=21
Phone=72
Skateboard=87
Frame=314
Days=365
Perfume=421

I want to get the value of "Skateboard" on file. So I need to read 9 lines. On the 9th line, the gets() loop will stop. But, what if I only want to get the value of "Skateboard" as integer (87) and not a string? Also, is it possible to scan the value of Skateboard if it's located on a different (or unknown) line?

View 1 Replies View Related

C++ ::  Going To A Specific Line Through Ifstream

Jan 12, 2015

I want to access specific lines in a "*.txt" file. I've heard of seekp() and what not, but don't know how to call them as such.

View 6 Replies View Related

C/C++ :: How To Find A Specific Value In Array

Mar 16, 2015

im having trouble with a function im writing. Its supposed to find the minimum value in an array and return the location of that value heres what i have so far :

int findLowest (int numb []) {
// findLow will hold the subscript of the lowest value in the array
int findLow = numb[0];
int x;
for (x = 0; x < 5; x++){
if (numb[x] < findLow)
findLow = x;
}
return findLow;
}

View 3 Replies View Related

C/C++ :: Overwrite One Specific Sector In HDD

Apr 26, 2015

I want to replace what is in a specific sector with value inside a buffer(dummy value). This code will read what is inside a specific sector. To make sure it works it display what is inside the sector and it displays the chosen dummy value. (the two cout's in main)

What I want to do is to replace the dummy value with what is inside the specific sector. So if the dummy value is '0', I want to replace what is in sector 285 with '0'.

#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
using namespace std;
#define FILE_SHARE_VALID_FLAGS 0x00000007
#define BUFFER_SIZE 512

[Code] ....

View 1 Replies View Related

C/C++ :: Getting Specific Info From A TXT File?

Oct 10, 2014

I'm trying to open a text file with the name "text.txt", for the purpose of only displaying in the console an specific part of the text file. For example, if I got "This is a test [TEXT] This is the message that should display [/TEXT] this is the end of the file", I want only "This is the message that should display" to be the output, the thing is that I can't imagine anyway of doing that. what I should do?

View 5 Replies View Related

C# :: How To Get A Specific List Element

Nov 26, 2014

Here's my list code:

Color.FromArgb(alfa, 0, 255, 255),
Color.FromArgb(alfa, 0, 255, 0),
Color.FromArgb(alfa, 64, 255, 0),
Color.FromArgb(alfa, 128, 255, 0),
Color.FromArgb(alfa, 192, 255, 0),
Color.FromArgb(alfa, 255, 255, 0),
Color.FromArgb(alfa, 255, 192, 0),
Color.FromArgb(alfa, 255, 128, 0),
Color.FromArgb(alfa, 255, 64, 0),
Color.FromArgb(alfa, 255, 0, 0)

How can I get a specific element value from that list?

For example:

if(true)
{
//get "192" from Color.FromArgb(alfa, 255, 192, 0)
}

I don't see the "Edit" option and I've noticed a slight error in the previous post.There should be, obviously, [code]if(true)

{
//get "192" from Color.FromArgb(alfa, 255, 192, 0)
}

I was missing the closing tag.

View 2 Replies View Related

C++ :: How To Display Item At Specific Tab Position

Nov 23, 2013

I used VB6 before to output file.

I set my output to file to tab(20) or tab(45) respectively.

In C++, how do I do this?

View 4 Replies View Related

C++ :: Saving Specific Bits From 64-bit Number

Jun 24, 2013

I have a 64-bit uint64_t number:

Code:
Primitive<uint64_t> b = 0xCCCCCCCC00000000; I need to save the first 31 (most important) bits - 7FFFFFFE.

I found this solution in the Internet:

Code:
start = (((b)>>(first)) & ((1<<(((last+1)-(first))))-1)); but in my case for this code:
Code: Primitive<uint64_t> start = (((b)>>(32)) & ((1<<(((63+1)-(32))))-1));

I get an error: left shift count >= width of type

And even if I change 63 to 62:

Code:
Primitive<uint64_t> start = (((b)>>(32)) & ((1<<(((62+1)-(32))))-1));

I get: error: integer overflow in expression

View 5 Replies View Related

C :: Add More Student Information To The Specific Txt File?

Mar 12, 2013

I'm trying to add more student information to the specific txt file. I did struct my student information and separated it with an array with max size of 200.

The inside of my current file looks like

Toshi
Aka
Nonal
Donald

The first one represent student[0] and next one is student[1] and so on till student[199]. Right now, only 4 space is occupied, which means the array has information till student[3] but not from student[4] (I guess it has null condition).

What I want to do is, I want to add a new student information to student[4] and till student[199] once at each time.

So, my prompt will look like
Would like to add a new student? Y/N
(if yes goes to below statement and exit if NO)
Hi. Please enter the information of new student. ___________
Student added. Please press any key to continue.

If the key is pressed, it goes back to my initial prompt and continues till I press N.

I sure I'm not using for loop to do this thing, because I'm adding student name one by one.

However, the array is already occupied by other student name till student[3] so, I want to add a new student information to student[4] (I don't want to overwrite the current information). And if student[4] is occupied, then [5] and so on.

View 7 Replies View Related

C :: Updating Specific Data In The File

Mar 17, 2013

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define MAX 200

[Code] ....

Inside of my studentinfo.txt file

Code:
Jnh Has 2353325 23 56 72 34 67 22 46 42 5 23 56 23
Daniel Laurent 6744590 10 20 30 40 50 60 70 80 90 100 40 50

This code is working totally fine. Right now, I'm trying to update a specific data from the student info. Let's say I'm trying to update my student number of Daniel. So, in this case, I want to replace 6744590 to some other student number. I think I have to use fseek() or rewind() and use fputs() but, I don't know how I should decide where to look.

View 8 Replies View Related

C :: Calculator - Input Specific Number?

Feb 11, 2013

In my calculator, I am trying to make it so that you put enter 1 to add, 2 to subtract, 3 to multiply, and 4 to divide. I am facing the issue of making it so that you must enter a number, however instead of it being any number, it must be 1, 2, 3, or 4, and if it is not any of those numbers, you must re-enter the number. Here is a little snippet of my code:

Code:

printf("Please enter 1 to add, 2 to subtract, 3 to multiply, or 4 to multiply: ");
while (scanf("%d", &input) != 1) {
while (getchar() != '
');
printf("Invalid option. Please try again: ");

[Code] ....

how I can make the loop affect specific numbers.

View 4 Replies View Related

C++ :: Program To Calculate How Many X Or / And Y From Specific Range

Nov 7, 2013

X and Y are numbers

For example: how many 2 or/and 5 are inside range of 0 to 30.
for or: there are 8 (2,5,12,15,22,25)
for and: there is only one (25).

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved