C :: When Run The Program Getting Segmentation Fault (core Dumped) Error

Mar 21, 2013

Here is the code, and I can get it to compile successfully, but when I run the program, I get a "segmentation fault (core dumped)" error. I am guessing it might be related to a buffer overflow but I cannot say for sure.

Code:
#include <stdio.h>
typedef struc {
int recordNo;
char name[20];
int qty;
float cost;

[Code] .....

View 1 Replies


ADVERTISEMENT

C :: Random Number Game - Segmentation Fault (core Dumped) Error

Jun 25, 2013

Ok, so doing an assignment for a random number game where you guess and it says too high or too low until you get it right or run out of tries. Here is what I got so far:

Code:
//Cameron Taylor

#include<stdio.h>
#include<stdlib.h>
#include<time.h>

int main(){
srand(time(0));
int number = rand()%100+1;;
int guess, numberGuess;

[Code] ....

Getting "Segmentation fault (core dumped)" after inputting the first number, but it compiles correctly.

I later have to add "Do you want to play again (y/n)", so I will use this post to continue that later.

View 13 Replies View Related

C :: Doing Histogram Using Pthreads - Segmentation Fault (core Dumped)

Apr 24, 2014

I am doing Histogram using pthreads and after long struggle on it.. finally it says 'Segmentation Fault (Core Dumped)'. I knew that error means something somewhere I am accessing to a wrong memory location.

Here is my code..

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

void Usage(char prog_name[]);
void Gen_data(void *p);
void Gen_bins(void *p);
int Which_bin(void *p);
void Print_histo(void *p);

[Code] ...

How to fix 'Segmentation Fault (Core Dumped)'?

View 2 Replies View Related

C :: Function That Sorts Dictionary List Alphabetically - Segmentation Fault (core Dumped)

Oct 9, 2013

Write a function that sorts a dictionary list alphabetically. Here's my code:

Code:

#include <stdio.h>
#include <stdbool.h>
struct entry
{
char word[15];
char definition[50];

[Code] ....

It's compiling ok, and displays the first call to the printf function from main. However, after this I get the 'Segmentation fault (core dumped)' at the terminal, presumably from the call to the dictionarySort function.

I had a little look around and found it is something to do with non-existent or not available memory addressing, I think? Even so, I can't figure out what is causing the issue in my code.

View 8 Replies View Related

C :: Segmentation Fault And Core Dump Creation

May 19, 2013

I'va got a segmentation problem with creation of core dump for the following snippet of c code:

Code:

#include
#include
#include
"lezione.h" studente s1, s2; studenti s;
int main()

{ int codice; char* nome; char* cognome; int esami;
printf("Leggi uno studente da tastiera e memorizzalo in una struct
");
lettura_studente(s1, codice, nome, cognome, esami); return 0;
}

[code]....

In conclusion I'va two problems:

1) Program crash;
2) I can't read struct studente within parameter function. What are the problems?

View 4 Replies View Related

C++ :: Using Least Mean Square To Fit A Sample Of Data - Segmentation Fault Core Dump

Apr 9, 2014

I'm writing a code using least mean square to fit a sample of data. The code is running till an iteration where it crashes and returns a segmentation fault core dumped

(the memory used is always closed to 2g mem=1805804kb,vmem=1926132kb, seems like the code can't go beyond) .

But If i try to fit at this last iteration the code works perfectly, so i think that I'm not trying to access a variable at a wrong index but it might be dynamic memory allocation ( a pointer to a matrix that I didn't free or something like that). The code is complex and calls too many routines, I'm combining cimg , c++ and old c. How can I track this error?

View 19 Replies View Related

C/C++ :: Binary Search Tree Program - Segmentation Fault Error

Mar 21, 2014

I'm writing a binary search tree program and I got it to compile but as soon as I input something it returns a "segmentation fault error" . I suspect the issue with the code is withing my `add` function.

template<typename T>
void BinarySearchTree<T>::add(T value) {
if (m_root == nullptr) {
Node<T>* node = new Node<T>;
node->setValue(value);
m_root = node;

[Code] ....

View 6 Replies View Related

C :: Keep Getting Segmentation Fault Error

Oct 28, 2013

Writing a program to search a file and print out the occurrences of each letter in the alphabet.

Code:

#include <stdio.h>
char input[500];
int input_c[26];
int i;
char count=0;
}

[code]....

View 8 Replies View Related

C++ :: Segmentation Fault - Memory Error When Looping Over Function?

Mar 24, 2014

It is been several days that I am stucked with the segmentation error and I do not know anymore what to do I try to do a loop over my function but it is working only for my first iteration. Here the code:

#include <iostream>
#include <cstdio>
#include <cstdlib>

[Code].....

I would like to iterate over solvep (since h is changing at each iteration..I usually add other fct but now I try to debug why the loop is not working.).The first iteration is working fine but not the other iterations.

View 4 Replies View Related

C :: Why Program Keeps On Getting Segmentation Fault

Jul 21, 2013

I can't understand why my program keeps on getting "Segmentation Fault". The last time I checked (in UBUNTU) it was already working, now I'm testing it in Windows and I keep on getting "Segmentation Fault".

Code:

#include <stdio.h>
#include <string.h>
int main(){
char string[1500];
char word[100];
}

[code]....

View 10 Replies View Related

C++ :: Get A Segmentation Fault With Program

Jun 28, 2013

I can't work out why I get a Segmentation Fault with my C++ program.

Here is the code:

#include <iostream>
#include <string>
#include <stdexcept>

[Code].....

View 5 Replies View Related

C :: Program Received Signal - Segmentation Fault

Sep 29, 2014

gdb result is

Code:
Program received signal SIGSEGV, Segmentation fault.
isoc99_fscanf (stream=0x0, format=0x4014e0 "%u %u %u %u")
at isoc99_fscanf.c:30
30 isoc99_fscanf.c: No such file or directory. Code:

[Code].....

View 2 Replies View Related

C :: Program That Provides Number Of Utilities For Strings - Keep Getting Segmentation Fault

Nov 22, 2014

I'm working on a program that provides a number of utilities for strings, but I keep getting segmentation faults and I cannot tell why. strContains works fine, but basically the rest of my functions throw seg faults.

Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"string_utils.h"

int strContains(const char * str,const char * subStr) {

[Code] ....

View 5 Replies View Related

C :: Program That Writes Words To Text - Segmentation Fault 11

Nov 25, 2013

I'm trying to make a program that writes words to a text. The words are generated by a brute force program. I am getting a segmentation fault 11...

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

static const char alphabet[] =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"1234567890";

[Code] .....

View 4 Replies View Related

C :: Calculate Product Of Two Matrices - Segmentation Fault In Program

Oct 29, 2014

New to C Programming, I have a problem with a little program I made that calculates the product of two matrices.

And here is the error I get:

View 4 Replies View Related

C++ :: Sum Of Diagonals Of Matrix - Program Giving Segmentation Error?

Jan 7, 2015

After entering the values of the matrix, it is giving me segmentation error. also "if possible", correct it

#include<iostream>
using namespace std;
int main()
{

[Code]......

View 2 Replies View Related

C :: Catch Segmentation Fault With GDB

Jan 23, 2013

I am working on a distributed application in C. My program gives segmentation fault and aborts execution. But, when I try to run it through gdb, it keeps on running although without giving a useful output. I realize that I do not put much information in my query. But, what general causes could generate this behaviour. I am interested to find the cause of segmentation fault.

View 8 Replies View Related

C++ :: Using Gdb To Detect Segmentation Fault In Sh?

Jan 16, 2015

I am using scientific linux. In the directory user/project/Build, after I ran 'make' to compile and link all the cpp files,I had no problems. But then, when I went to directory user/run/run.sh, which runs the project binary in user/project/Build/bin/project, I get a segmentation fault error. In the directory user/run, I enter 'gdb' in the command prompt and get the message "*** No targets specified and no makefile found. Stop." What am I supposed to do to detect the segmentation fault?

View 2 Replies View Related

C++ :: Getting Segmentation Fault Using Maps?

Dec 7, 2014

GameMaster.h
#includes ...
class GameMaster
{

[Code].....

I get the segmentation fault whenever it tries to insert the first player.. however whenever i do this :

void MakeSquad(char type, string name, int coordX, int coordY, char dir, int squad)
{
GameSpace::MapSquadType MapOfSquads;​
MapOfSquads.insert(make_pair(name , Squad(squad)); // Squad( int ) just converts the int squad number to the Enum.
}

I do not get any errors or segmentation faults..

View 5 Replies View Related

C++ :: Segmentation Fault And Also Bad Initialization

Feb 25, 2012

Code:

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#define FILEPATH "./input.txt"
#define FILEPATH2 "./copy.txt"

[Code] ....

The problem is probably the fact that I'm using the variable s in the wrong way, but as I'm very bad at C and C++, at least so far anyway, I've no clue what's wrong. Is it my size that I passed in the marked method?

Also, how do I tell it, later, once this starts to work, to pass the file name of the file it'll copy to as the first param and the file it reads from to the pipe as the second param?

I'm supposed to be reading from a file, and as I was given some code, but it's probably in C and not C++, even if it is, I'm still not that great at C++ either, but anyway, I'm to have the program read from the file and write to the pipe and have the child read from the pipe and write to the output file.

FileCopy copy.txt input.txt

View 14 Replies View Related

C++ :: Get 15 Names And Then Hash Them - Segmentation Fault

May 3, 2013

The point of this code is to get 15 names and then hash them. After one name is entered I get a segmentation Fault and the program crashes.

Code:
//driver file
#include <iostream>
#include <vector>
#include <string>
using namespace std;

[Code] ....

View 7 Replies View Related

C++ :: Argv To String Segmentation Fault?

May 29, 2013

I have this piece of code that causes segmentation fault:

Code: .... check argv[2] exists ....
std::string* op_file;
...
std::cout << "argv[2] is: " << argv[2] << std::endl;
op_file = new std::string(argv[2]);
...

The result I am getting is:

Code: argv[2] is: somefile.txt

Segmentation fault (core dumped)

View 3 Replies View Related

C :: Segmentation Fault In Header File?

Apr 26, 2013

I have written a small program for a class to convert decimal to binary and the program itself works, however, I am storing the binary bits in a stack that is in a header file (which I have used successfully before). It appears to push the bits to the stack just fine, however, when I use the printStack function I get a segmentation fault.

Here is the stack.h header file:

Code:
#include <stdlib.h>
#include <stdio.h>
struct stackNode {
int data;
struct stackNode *nextPtr;

[Code].....

And here is the main program that does the conversion:

Code:
#include <stdio.h>
#include "stack.h"
int binary (int x);
int main() {
int choice = 0;
printf("

[Code].....

One other thing of note, whenever I try to modify the printStack function, that function then seems to not work at all.

View 12 Replies View Related

C :: Segmentation Fault At Free Call

Jul 7, 2014

Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
/* h(a)=abcab,h(b)=acabcb,h(c)=acbcacb */
void h_i(int i, char *w, char *a, char *b, char *c)

[Code] .....

Above program increases string like this example.

Let say h(0)=01 and h(1)=10 and let say our first string is w=0 h(w)=01, h^2(w)=0110 h^3(w)=01101001..etc.

We have used h map, which is given in the program comment statement. Same thing, program is doing for three letters. These three letters we have passed as argument in h_i function. e.g. h_i(2,w,"a","d","g") function will apply the 3 letter map h(definition is given in commented form in program) 2 times on string w.

In program w=a; and three letters are a, d and g. /* h(a)=abcab,h(b)=acabcb,h(c)=acbcacb */ here b=d and c=g.

Above program gives core dump at free(w2) free(w1). if we remove these free statements then it gives correct answer. But, we want to free w1 and w2 in the above code. How can we make free both w1 and w2 strings?

View 4 Replies View Related

C :: Segmentation Fault Could Not Find After Debugging

Apr 15, 2013

I want to know what was wrong with my code when I submitted. It's a Traveling Salesperson Problem, and the code is complete for the most part. I just can't seem to find what's causing the segmentation fault even after attempting to debug with gdb. Something is supposed to be wrong with line 76, but I don't see how my arrays are messing up. I've looked through this code countless times, and I know I'm just missing something small. I just don't want to end up making whatever mistake I made on this again in the future.

Code:

#include <stdio.h>
#include <stdlib.h>
#define SIZE 20

[Code]....

View 9 Replies View Related

C :: Random Variable - Segmentation Fault

Feb 18, 2013

I am having trouble running the following code. I am getting a message segmentation fault (core dumped)

Code:
#include<stdio.h>
#include<ctype.h>
#include<time.h>

main() {

int iuser;
int irand;
srand(time(NULL));

[Code] .....

View 2 Replies View Related







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