C/C++ :: No Output When Implement Own Strcpy Function

Aug 20, 2014

I am trying to implement own strcpy function, but no output is being printed.

#include<stdio.h>
#include<string.h>  
void strcpy_own(char dest[], char src[], int len);  
int main() {
    char src[15]="jeevan", dest[15];

[Code] ....

View 3 Replies


ADVERTISEMENT

C/C++ :: Implement Breadth First Search Graph And Output Order Of Traversal

Mar 26, 2014

I'm new to program breadth first search and for my assignment we have to implement a breadth first search graph and output the order of the traversal. The problem is when I run my program I do not get any output from my traversal. All I get is "Breadth First Search Traversal starts at Vertex 2 and the order is: "

Here is my Queue class

//Declaration of node
struct node{
int info;
node *next;
};
//Defining Queue class
class Queue{

[Code] ....

View 4 Replies View Related

C :: Implement Setjmp For Function?

Feb 23, 2015

I am trying to implement setjmp for functions.

Code:
#include <setjmp.h>
#include <stdio.h>
jmp_buf arr[3];
void DISP(int x , int i)

[Code]....

Could I possibly use malloc to allocate memory for the stack too?

View 1 Replies View Related

C :: How To Use Strcpy On 2D Array

Sep 20, 2014

how to use strcpy on a 2D array. The names of the students are suppose to go along with the correct score(descending order).

Student's name are:
Jack 83
Pete 100
Shawn 75
Tim 40

Turns out according to their score:
Pete 100
Jack 83
Shawn 75
Tim 40

Code:

char students[20][50];
char name[20];
temp = 0;
for(i = 0; i < count; i++){
for(j = i + 1; j < count; j++){
if(averageScore[j] > averageScore[i]){
temp = averageScore[i];

[Code]....

View 7 Replies View Related

C :: Using Strcpy For Arrays

Feb 2, 2013

I am attempting to assign "randomChoice" as the array index of the "listOfWords" array then copy "listOfWords[randomChoice] to "selectedWord". I am not sure if it is that I do not fully understand the use of strcopy() or something wrong with my arrays.

This is my error:

Code:

hangman.cc: In function ‘void SelectWord(char (*)[80], int, char*):
hangman.cc:84: error: invalid conversion from 'char' to 'const char*' And my code:
Code: #include <iostream>#include <fstream>
#include <cstdlib>
#include <cassert>
#include <cstring>

[code].....

View 4 Replies View Related

C++ :: Strcpy Gives Seg Fault

Dec 28, 2014

I am trying to practice different concepts in C++ programming. Following is the program which compile successfully but gives seg fault at runtime.

#include <iostream>
#include <string.h>
using namespace std;
class A {
char *name;
int i,j;
const double k;
static float l;
int &m;

[Code] ....

View 5 Replies View Related

C/C++ :: How To Implement Pointers To Call The Function

Mar 11, 2014

write a program which contains two global variables:

1.Account number (integer)
2.Account Balance (float)

and three functions :

A function called set values which sets initial values for account number and account balance,

A function called set values which prompt user to enter the values of the above variables,

A function called input transaction which reads a character value for transaction type that is D (for deposit) and W (for withdrawal ) and a floating point value for transaction amount which updates the account balance .

Implement a pointer to call each of the functions using C++.

View 1 Replies View Related

C++ :: How To Implement Mean1d Function To Find Mean

Nov 2, 2013

Code:
#include <iostream>
using namespace std;
int main() {
//I'll be making a 1 dimensional array
int array1d[25];

[Code] .....

View 1 Replies View Related

C :: Using Strtok And Strcpy In File

Sep 27, 2014

How to use strtok and strcpy in a file?

View 1 Replies View Related

C++ :: Implement Simple Wrapper For Logging Function

Jul 22, 2014

I need to implement simple wrapper for logging function log(const char *). So the solution is below:

#include <stdio.h>
#include <sstream>
using namespace std;
void log(const char * str){ printf(str);}

[Code] ...

So, according to standard the temporary objects should not be destroyed before full expression execution (expression whitch is not a part of another expression).

The question is: is StreamLogger() << "foo1" << "foo2" << "foo3"; full expression or not?

View 2 Replies View Related

C++ :: BEEP Function - How To Implement Morse Code Program

Mar 2, 2013

Code:
#include <iostream>
#include <windows.h>
#include <iomanip>
using namespace std;

[Code] .....

I'm trying to implement Morse code program. However, I cannot find any codes which make a time gap between the letters. How the time gap code?

View 4 Replies View Related

C++ :: Implement Quick Sort Algorithm Using Recursive Function

Feb 13, 2013

I have written this code to arrange user input array in an order.

//Recursive Quick Sort
#include<stdio.h>
#define ARRAY_SIZE 10
void quick_sort(int array[], int len)
}

[code].....

View 6 Replies View Related

C++ :: Singleton Base Class - How To Implement GetInstance Function

Aug 20, 2014

I'm playing with the idea of a singleton base class, but I'm having an issue with how to implement the GetInstance() function in the base class. Since I'm trying to make this ridiculously simple for the child, I'd like to handle that in the base.

class Singleton {
private:
static Singleton* instance;
Singleton() { Construct(); } // Private to avoid other instances

[Code] .....

It would be easy to use like so:

class Hello : public Singleton {
private:
std::string hello;
void Construct() { hello = "hello"; }
public:
std::string GetHello() const { return hello; }
};

Then the instance would be handled like so:
std::cout << Hello::GetInstance()->GetHello();

View 12 Replies View Related

C++ :: Implement Member Functions Of Class Function - Failing To Get Input

Aug 17, 2013

I am supposed to implement the member functions of class Person.

class Person {
public:
Person();
Person(string pname, int page);
void get_name() const;
void get_age() const;

[Code] ....

The code I wrote is below. Where I am struggling is the program does not allow me to input age. Therefore, I cannot test if my temp for age works. It automatically defaults to 0 because it hasn't taken input. Here is my code:

// Program Title: Person function
// Program Description: The program prompts the user for first and last name and age.
// It then prints the output that was provided by the user.

#include<iostream>
#include<string>
using namespace std;
class Person {

[Code] .....

View 13 Replies View Related

C++ :: Binary Search Tree - How To Implement Insert Function Properly

Nov 18, 2013

I am unable to implement the insert function properly, every time i run the program i just get the first value and name, I am not getting other Id's and name.

"(Header File)"
#include <iostream>
#include <string>
using namespace std;
class node{
public:
int ID;
string name;
class node *left, *right, *parent;

[Code] .....

View 4 Replies View Related

C :: Strcpy - How To Update Old String In Stars Array With New That Includes Correct Letters

Apr 25, 2013

This for loop replaces the stars ******** in an array that contains a word to be guessed with the correct letter (c) that the user inputs if the word contains that letter.

Problem: After every guess the same hidden string of stars ******* is displayed instead of ex: ***W**** (assuming W was entered by the user)

How can I update the old ******** string in the Stars array with the new string that includes the correct letters chosen, so after every correct guess at a letter in the word a new string is displayed including the correct letters chosen?

I'm pretty sure I have to use strcpy but not sure how to implement it using a loop.

Code:
for(i = 0; i < strlen(unscrambledWord); i++) {
if(unscrambledWord [i] == c) {
Stars[i] = c;
} }

View 1 Replies View Related

C++ :: How To Use One Function Output In Another

Mar 17, 2013

In my code the cout phrase is supposed to give me an angle in degrees. no matter which 2 points i enter in, it always outputs the angle between them to be 57. This is because the acos value of 0 in degrees is 57. The program compiles without error.

Here is the code:

/*
Synopsis: This program reads in the coordinates of two 2D vectors and outputs the angle between the vectors in degrees.
*/

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
// function prototypes
// ENTER FUNCTION PROTOTYPE FOR normalize() HERE.
void normalize(double & x, double & y);

[Code] .....

View 2 Replies View Related

C++ :: Unexpected Output In Example Function

Jan 21, 2015

I am currently trying to understand why this example for using an array as an argument in a function has a different result than what the lecture notes say it should be.

So supposedly sum should return with the value 28, but I get 27 no matter what. I also am not very good at reading and understanding what exactly the order of operations for this function are.

Code:
#include <iostream>
using namespace std;

int sum(const int array[], const int length) {
long sum = 0;
for (int i = 0; i < length; sum += array[++i]);
return sum;

[Code] ....

View 3 Replies View Related

C/C++ :: Function Output For Three Lines

Nov 23, 2014

I am doing a written lab in my programming class in which we must write the output for three lines in a function. However, when I enter the code in my compiler I only get error messages. I was just wondering what the outputs under snap, crackle and pop should be and why.

#include <iostream>
using namespace std;
void snap (int i, int j);
void crackle (int &a, int &B)/>;
void pop (int &e, int f);
int main () {
int i = 1, j = 2;

[Code] .....

View 4 Replies View Related

C++ :: Need Cout To Print Function Output?

Nov 16, 2013

Finally got to functions. Made a simple one that adds two numbers:

Code: int add(int a, int b){
cout<<"a+b=";
return a+b;
}

It refuses to give an output unless I use cout.

If I just call the function like so: "add(12, 24);", shouldn't it print out a+b=36? It only prints out "a+b=", unless I use "cout<<" ahead of the call.

My simple question is why does it need cout ahead of the call? Shouldn't "return" do its job and print out the number?

View 2 Replies View Related

C :: Positive Binary Output Function

Mar 27, 2013

I have written a function that takes in a positive decimal and returns its Binary equivalent; however, the output always adds an additional zero to the binary. What could I do to get rid of it?

If the number is 7, it outputs 0111 instead of 111.

Code:
#include <stdio.h>
void Dec(int n) {
if(n > 0)
Dec(n/2);
printf("%i", n%2);

[Code] ....

View 2 Replies View Related

C++ :: Input And Output Array Using Function

Apr 25, 2013

I want to create a function that will accept input from the user and return the input, to be used for further calculation. I know how to accept and return with integers as parameters , but how do i do it with arrays?

Suppose there is an array of numbers arr[]. Now, i want a function that accepts the input from the user, and return the array for further manipulation.

For example, if the array is arr[5], then i should call a function and accept the values from the user. Then, i should return the imputed values and print the same. How can i do this.

View 3 Replies View Related

C++ :: Call Function To Output Data?

Dec 10, 2014

I am having an issue with my Call Function to output data. The compiler doesn't like the Call function to output data.

#pragma once
namespace WindowsFormsApplication1 {
using namespace System;

[Code].....

View 1 Replies View Related

C++ :: Printing Function Output To A File?

Oct 11, 2013

I have to convert a binary value from an input file (the name of which is given by the user) and then convert the binary to decimal value and print that in an output file.

Right now it is compiling just fine with no error messages, but when I run the program, it doesn't end or print to the output file.

Here is my code at the moment:

#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <fstream>

[Code].....

View 2 Replies View Related

C/C++ :: Output Is Getting Scattered After Using Curses Function

Jan 13, 2013

 #include<iostream>
 #include <ncurses.h>
 #include <curses.h>
 using namespace std;
 int main() {
 initscr(); // Initalise the ncurses library

[Code] ....

It prints table upto 10 really wel but after 10 all tables get scatterd .

View 1 Replies View Related

C++ :: Can't Output Decimal Number From A Function Result

Mar 28, 2013

I have this simple code here:

Code:
#include <iostream>
int multiply (double x, double y) {
double result = x*y;
return (result);

[Code] ....

I get the answer 5.94 (which is what I'm looking for). I can't work out why the first example is not outputting a decimal number. I have set the variables as a double so I just can't see why this is not working for me.

View 1 Replies View Related







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