C :: Create Separate Array That Consists Of The Same Number

Mar 6, 2015

I working on a big program, and it involves character arrays. What I want my function to do is create a seperate array that consists of the same number of "*" as there are letters in the word from the text file. For example, if the word sarc was up, the function show make ****. This was my attempt at it. I managed to reach this far. I can only fit in one "*". This is part of jumble game program I'm trying to make, and its in C language.

insert Code: void partialWord(char current[]){
int n;
int i;
n = strlen(current);
for (i = 0; i < n; i++){
current[i] = strcpy(current,"*");
}
printf("%s
", current);
}

View 7 Replies


ADVERTISEMENT

C++ :: Create User Defined Class And Have Access In Separate Header File From Main

Mar 15, 2013

I am a beginner with C++, taking a class right now. The lab this week is to create a user defined class and have it accesses in a separate .h header file from the main.

I think I'm finding my way through it, but I'm getting a complie error that makes no sense to me:

1> Resistor.cpp
1>c:users omdocumentsschoolcomp 220week 2lablab 2.2lab 2.2
esistor.h(11): error C2146: syntax error : missing ';' before identifier 'resistor'
1>c:users omdocumentsschoolcomp 220week 2lablab 2.2lab 2.2

[Code] .....

Here is the first portion of the .h file:

#include <iostream>
#include <iomanip>
#include <Windows.h>
#include <math.h>
#include <string>

class CResistor{
double res1, res2, res3, percentage, Nominal, Tolerance;

[Code] ....

View 16 Replies View Related

C++ :: Design And Implement A Program That Consists Of Two Classes?

May 15, 2013

I am trying to design and implement a program that consists of two classes. The Base class A is purely for supporting class B. I do not want to be able to create an object of class A. When object B is created it inherits from class A.

What is the best way to achieve this?

View 8 Replies View Related

C :: Read 15 Numbers And Display Each Number On Separate Line

Oct 21, 2014

Program to read in 15 numbers and display them as follows //each number on a separate line

Code:

# include <stdio.h>
# define MY_ARRAY 15
int main(){
int i ;
printf("please enter 15 numbers

[Code] ....

Error that i get from compiler:
Error E2062 array1.c 14: Invalid indirection in function main()
Error E2062 array1.c 19: Invalid indirection in function main()
both pointing to the separate "scanf"

View 6 Replies View Related

C/C++ :: How To Print Random Number Asterisks On Two Separate Lines

Apr 20, 2015

Im trying to figure out how to print a random number of asterisks on two separate lines at the same time. So every time you press a key it prints a different amount of random number of integers between1 and 10 until one of the lines reaches 70. I have the code to do one line but can't figure out how to do two at once.

#include <stdio.h>
#include <time.h>
#define MINR 1
#define MAXR 70
#define MINM 1
#define MAXM 10
int main (void)

[Code]...

View 2 Replies View Related

C++ :: Create Save File For A Game That Is Not A Separate File?

Oct 10, 2014

How do you create a save file for a game, that is not a separate file? Specifically I am using code::blocks and sfml 2.1 to make a game and it saves to a text file at the moment. My problem is that it is very easy to modify the text file, and it is annoying to have to copy and paste several files if you want to use a copy of the game. I have a feeling that it may be to do with resource files, but I'm not exactly sure how to get these to work or whether you can modify them dynamically.

View 6 Replies View Related

C/C++ :: Separate Byte Of Array Into Nibble For New Array

Oct 1, 2012

How can I separate byte array and put nibbles in a new array?

when I try following:

byte in[]={0xab,0x11,0x22,0x33,0xbb}; 
byte out[10];  
void seperatebyte(byte* input, byte* output) {  
  for(int i = 0;i<sizeof(input);i++)  {   
        output[i*2]  = (input[i] >> 4) & 0xf;
        output[(i*2)+1]  = input[i] & 0xf;
     }  
}  

seperatebyte(in,out); //gives output of  

10 11 1 1 184 1 184 0 0 0

I expect 10 11 1 1 2 2 3 3 11 11

View 2 Replies View Related

C :: Splitting String Into Separate Characters Or Array

Feb 18, 2014

I have been looking everywhere, but the only place I have seen it done is Objective C. The Question: how do I split a string, input by the user, into an array of characters? No code shown because I know no commands that do this.

--Input by user as in fgets, or scanf().

View 2 Replies View Related

C :: Make A Hash Table Array Of Linked Lists / Separate Chaining Technique

Jul 5, 2013

how to create a hash table array and use linked lists inside the elements.

View 5 Replies View Related

C :: Create Function To Create A Dynamic Array That Fill With Randomly Generated Integers From 0 To 50

Oct 26, 2013

I have a struct called Array and I'm to create a function to create a dynamic array that's fill with randomly generated integers from 0 to 50 (inclusive) and a function to destroy the array for freeing its memory. Below the code that I have written so far.

Code:

* Struct */
typedef struct {int *pArray; //the dynamic array
int length; //the size of the dynamic array}Array;
/* Function to create a dynamic array */
Array *initializeArray (int length) {int i;
}

[code]....

View 7 Replies View Related

C++ :: Create Random Number As Zip Code

Nov 21, 2014

I am trying to create a zipcode I write my code like that and it only show "-2" on the screen what happen to my code I can not find mistake!

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <ctime>
using namespace std;
class Zipcode {

[Code] ....

View 1 Replies View Related

C++ :: Create A Specific Number Of For Loops Each In Another Loop

Sep 18, 2014

I want to create a specific number of for loops each in another loop, as in example:

for(i=0;i<9;i++)
{
for(j=0;j<9;j++)
{
for(k=0;k<9;k++)
{
//some stuff
}
}
}

In this example there are 3 loops, but what if i want to create e.g. 10 such loops, and program reads a number of loops from a txt? It is needed for checking numbers.

View 2 Replies View Related

C++ :: Create A Function With Integer Number As Parameter

Jun 20, 2013

I must create a function with a integer number as parameterThis function use the parameter for a loop...example

n = 1
output
1
2
3

n = 2
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3

View 1 Replies View Related

C++ :: Create Single Integer Number From Four Integers

Mar 1, 2014

Write a program that reads four integers from a file ‘input.txt’.

The program will then create a single integer number from the four integers. The output of the program will be the single number and single number + 600.

#include <iostream>
using namespace std;
int main () {
int number , a;
cout<<"enter en integer number";
cin>>number;
cout<<"add 600 to the number"
cin>>a=number+600;
return 0;
}

View 5 Replies View Related

C :: Create A Program That Prints A Number Of Dots Specified By User

Oct 8, 2013

I'm trying to create a program that prints a number of dots specified by the user, there 4 options to do any loop type or to exit the menu. i'm having problems making it so that after you enter a value and it displays the specified number of dots it clears the results. Also we have to make it so that if a negative integer is entered it still prints out the appropriate amount of dots ie: user puts -9 it prints 9 dots, i know you use the abs() function but it doesn't seem to be working for me. I'm assuming my problem with the abs function is i'm not using it correctly. Use case 1 as the example for the rest because I'm trying to implement everything on one case at a time

Code:

int main() {
//initialization statements
int Num1 = 0;
char dot = '.';

[code]....

View 7 Replies View Related

C++ :: How To Create CPP File That Will Handle Random Number Generators

Jul 23, 2014

How to create .cpp file (new class) that will handle all the random number generators (<random> library) that main could possibly access. When I looked for a way how to implement random generators the examples were always in the main function or in a class in the main.cpp (with no header file and the generator was not seeded as I imagine it should be = only once in a program).

Questions follows after this malfunction code.

main.cpp
#include "randomizer.h"
int main() {
Randomizer randObject(0, 10, 125); //Set bounds and seed generator
int mainVar = randObject.getRandInt(); //Store newly generated random number for future work

[Code] .....

1) So I think that I should somehow declare these generators and distribution in the header file. Is it like declaring int a;?

I tried writing std::default_random_engine defGen; into the header file which only silenced compiler's errors but defGen wasn't seeded.

I have seen some examples using auto a = randInt(defGen); (or maybe with the use of auto a = std::bind.... But what does auto represent? I can't use it in the header file.

2) Can I ensure that the randObject is seeded only once? If for examle I need randObject2 with different boundMax, can I still use the same defGen which was seeded the first time? That should ensure better "randomness" through the program, shouldn't it?

3) Is there better way (and easy too) to "interface" random number generators? The class in the end should provide "get" function to acces int, double, bool, signed/unsigned... or some other specialities like random prime numbers, etc.

If it is anyhow related I am using Code::Blocks IDE with GCC compiler (4.7.1)

View 4 Replies View Related

C++ :: Create Program That Has User Input 5 Digit Number?

Mar 9, 2013

Im trying to create a program that has the user input a 5 digit number. If it's between 10000 & 99999, it will do one thing..(just saying 'yes' for now. Outside those numbers will prompt the user to input again. However, if the user inputs the exact digits 76087, it should display 'term'.

This current code is displaying 'term' whenever the user inputs the 5 digits.

Code:

#include <iostream>
using namespace std;
int main() {
int pin;
cout << "Welcome to Movie Food
Enter your 5-digit pin code: " ;

[code]....

View 14 Replies View Related

C/C++ :: Create A Program That Prints A Certain Number Of Asterisks Based On User Input

Apr 12, 2015

I need to create a program that prints a certain number of asterisks based on user input. The user inputs 5 and I want my program to output "*****". How would I do this in C? I've tried printf("%#**", myvariable) but this does not work it only prints "*".

View 1 Replies View Related

C++ :: Create Array Of Playing Cards / Assign Values And Suits Then Shuffle The Array

Nov 24, 2014

I got this program to create an array of playing cards and assign the values and suits and shuffle the array. I'm at the point where I need to output the cards but I need to burn the first card by making it output "**" instead of the card. my cards[] is a constant so I can's assign the first card as such.

void showCards(const int cards[], int numCards, bool hideFirstCard) {
if (cards[0]) {
hideFirstCard=true;
cards[0] = '**';
} for(int a = 0; a <= numCards; a++) {
cout >> showCard(cards[a]);
} }

View 1 Replies View Related

C :: Create A Box Outside Array?

Dec 1, 2013

I am trying to create a box outside my 9x9 array. However, my box did not cover up everything.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>

#define row 19
#define col 19

[Code] ....

View 6 Replies View Related

C++ :: How To Create Array Of Nodes

Feb 10, 2015

I am trying to see if I can create an array of nodes. I think I have it down somewhat but this is what I have.

Code:

#include <iostream>
using namespace std;
/*This is a template of a person....sorta*/
class person{
public:
int data[32];
bool selected = false;
person(){

[Code]...

I am trying to see if there is a way for me to create a 86 slot array of person nodes. I am not sure how to do it and how to access them afterwards. I know that I am creating the bitstring of person correctly but I am not sure how to get the array of person going.

View 7 Replies View Related

C :: How To Create 8 Dimensional Array

Dec 19, 2014

Is it possible to create an 8 dimensional array in C? If no, then what can I do to improvise or let say bypass the limit?

View 7 Replies View Related

C :: How To Create Array Of Arrays

Nov 3, 2014

I wanted to do this: Accept a line of input from user and save it to an array1 and copy its contents to other array in a set of arrays and then input another line to array1 and then copy it to next array in the same set and so on.... I know it is confusing but I can put it like that I want to create an array of arrays (Set of arrays). How can I do so?

I wrote a code to input the line in an array and tried to copy it another array of pointers, but pointers are just addresses so the same adress is copied again and again so, all the pointers of the array point to one address only. The code doesn't print anything when I try to print all the lines that were saved.

Code:
#include <stdio.h>
#include <stdlib.h>

#define MAXLEN 1000
#define MAXSIZE 100

int getline(char [], int );
void storage(char line[]);

[Code] .....

View 2 Replies View Related

C :: Program To Create 2D Array For Each Row

Feb 14, 2013

What I am trying to do is to have the program create 2D array that for each row, no two numbers are the same and only consists numbers between 1-9. The array lists out every possible combinations. Supposely I do not know the number of possible combinations, I had it keep adding new rows until there are no more possiblities left.

The problem with my code is when I print out the completed array, it gives out really, really large numbers. But when I print the array from inside the first loop, it gives correct values. I do not know exactly what happened.

Code:
#include <stdio.h>
int main(void) {
int double_digit[1][2];

int a = 1;
int b = 1;

[Code] ....

View 5 Replies View Related

C :: How To Create Array Who Point To Some Value

Oct 15, 2014

I have to create dynamic array, where each element of it points to some value. I know how to create dynamic array

Code: array_record * record_1 = (array_record*)malloc( (group!/(2!(group!-2)!)) *sizeof(array_record));

But i don't know how i create this case. for example what i want if array elements are:

Code:

index value value
0 01 -> 345
1 02 -> 457
2 03 -> 689
3 21 -> 634

so if i have value somewhere 01 match with 01 in this array it display 345. how i can implement it?

View 1 Replies View Related

C++ :: Use 3D Array To Create Image

Sep 16, 2014

My assignment is use a 3D array to create an image. Use an array of the form arr[300][200][3]. For this homework, you need to use an array of the form arr[3][400][500]. It will have 400 rows and 500 columns. You need to first initialize the array as described in class and after that write the array to a ppm image file. When viewed using Gimp, it should display USM. The letters would be 200 pixels high and 100 pixels wide each. Use at least 15 pixels for the width of the stroke. Use different colors for each letter and a different color for the background.This is what I have so far.

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

void initialize(unsigned char a[][200][3], int nrows, int ncols, int nc);
void printAll(unsigned char a[][200][3], int nrows, int ncols, int nc);

[code]....

View 3 Replies View Related







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