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
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
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
Sep 27, 2014
How to use strtok and strcpy in a file?
View 1 Replies
View Related
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
View Related
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
Mar 25, 2014
identify the reason why I am getting a seg fault run error? I hate to bother but I've been trying for several days now to fix the same function.
class adjacencyList {
public:
explicit adjacencyList(int size);
void buildGraph(Edge inEdge);
void print();
[code].....
View 6 Replies
View Related
Oct 17, 2013
I have a c source file:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <regex.h>
typedef struct
[Code] .....
But the problem is i get a seg fault at the read function.
View 2 Replies
View Related
Mar 9, 2013
I've received a segmentation fault in this part of code:
Code:
for (; str[i] != '