Search Results

Search found 559 results on 23 pages for 'segmentation'.

Page 17/23 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • reading a file that doesn't exist

    - by John
    Hi, I have got a small program that prints the contents of files using the system call - read. unsigned char buffer[8]; size_t offset=0; size_t bytes_read; int i; int fd = open(argv[1], O_RDONLY); do{ bytes_read = read(fd, buffer, sizeof(buffer)); printf("0x%06x : ", offset); for(i=0; i<bytes_read; ++i) { printf("%c ", buffer[i]); } printf("\n"); offset = offset + bytes_read; }while(bytes_read == sizeof(buffer)); Now while running I give a file name that doesn't exist. It prints some kind of data mixed with environment variables and a segmentation fault at the end. How is this possible? What is the program printing? Thanks, John

    Read the article

  • Codesample with bufferoverflow (gets method). Why does it not behave as expected?

    - by citronas
    This an extract from an c program that should demonstrate a bufferoverflow. void foo() { char arr[8]; printf(" enter bla bla bla"); gets(arr); printf(" you entered %s\n", arr); } The question was "How many input chars can a user maximal enter without a creating a buffer overflow" My initial answer was 8, because the char-array is 8 bytes long. Although I was pretty certain my answer was correct, I tried a higher amount of chars, and found that the limit of chars that I can enter, before I get a segmentation fault is 11. (Im running this on A VirtualBox Ubuntu) So my question is: Why is it possible to enter 11 chars into that 8 byte array?

    Read the article

  • A programming language for teaching data structures and algorithms with? [closed]

    - by Andreas Grech
    Possible Duplicate: Choice of programming language for learning data structures and algorithms Teachers have different opinions on what programming language they would choose to teach data structures and algorithms with. Some would prefer a lower level language such as C because it allows the student to learn more about what goes on beyond the abstractions in terms of memory allocation and deallocation and pointers and pointer arithmetic. On the other hand, others would say that they would prefer a higher level language like Java because it allows the student to learn more about the concepts of the structures and the algorithm design rather than 'waste time' and fiddle around with memory segmentation faults and all the blunders that come with languages where memory management is manual. What is your take on this issue? And also, please post any references you may know of that also discuss this argument.

    Read the article

  • Can Wordpress Duplicate An Entire Page Structure?

    - by rob walsh
    I have a wordpress site that i've been working on that has some pages (as in NOT posts) that a client changes content on in order to target particular keywords. these pages have been using podscms for content management. The client now wants to be able to duplicate these pages any number of times and edit the text within them. So basically, he wants to be have a dozen or so versions of about 4 linked pages. Does anyone know if it's possible to duplicate an entire multipage structure like this in WP? Or any WP driven sites that implement segmentation similarly?

    Read the article

  • Botan::SecureVector - Destructor called in Constructor???

    - by sheepsimulator
    When using the Botan::SecureVector in the following unit test: void UnitTest() { std::vector<byte> vbData; vbData.push_back(0x04); vbData.push_back(0x04); vbData.push_back(0x04); Botan::SecureVector<Botan::byte> svData(&vbData[0], vbData.size()); CPPUNIT_ASSERT(vbData == std::vector<byte>(svData.begin(), svData.end())); } a segmentation fault occurs when trying to allocate the SecureVector.

    Read the article

  • Debug error in NetBeans

    - by avd
    I am running a C program in NetBeans (cygwin on windows). Generally for all C programs I have run in the past, while debugging, it stops and shows the line number of segmentation fault. But for this particular program, it does not show the line number and just stops and in the output tab, it shows prog stopped by SIGSEGV. I have tried conditional breakpoint, but it is not stopping. What could be the other conditions for error? If u want have a look at my program, here it is.http://codepad.org/cujYTIeg and the in.txt file from where it reads the input. http://codepad.org/vNySA6uh

    Read the article

  • findNode in binary search tree

    - by Weadadada Awda
    Does this look right? I mean I am trying to implement the delete function. Node* BST::findNode(int tofind) { Node* node = new Node; node = root; while (node != NULL) { if (node->val == tofind) { return node; } else if (tofind < node->val) { node = node->left; } else { node = node->right; } } } Here is the delete, it's not even close to done but, void BST::Delete(int todelete) { // bool found = false; Node* toDelete = new Node(); toDelete=findNode(todelete); if(toDelete->val!=NULL) { cout << toDelete->val << endl; } } This causes a segmentation fault just running that, any ideas?

    Read the article

  • Global list in C/gtk+

    - by sterh
    Hello, I need in global list in my gtk+ application, i use for it GList: For example: I have structure: typedef struct _data { Glist list; }Data; I want to use one copy of the list in the whole program: I have a function bulid my list: gboolean build_list() { Data->list = g_list_append(mw->a, "First "); Data->list = g_list_append(mw->a, "Second "); Data->list = g_list_append(mw->a, "Third "); g_list_foreach(Data->list, (GFunc)printf, NULL); } After calling this function to display all items in the list. zbut when i try to make it in another function - for example: void foreach() { g_list_foreach(Data->list, (GFunc)printf, NULL); } I see error in gdb: *Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb7335700 (LWP 5364)] 0xb765a7d7 in strchrnul () from /lib/i686/cmov/libc.so.6 * How can i create global list in my application? Thank you.

    Read the article

  • Are macro definitions compatible between MIPS and Intel C compiler?

    - by Derek
    I seem to be having a problem with a macro that I have defined in a C program. I compile this software and run it sucessfully with the MIPS compiler. It builds OK but throws the error "Segmentation fault" at runtime when using icc. I compiled both of these on 64 bit architectures (MIPS on SGI, with -64 flag and icc on an intel platform). Is there some magic switch I need to use to make this work correctly on both system? I turned on warnings for the intel compiler, and EVERY one of the places in my program where a macro is invoked throws a warning. Usually something along the lines of mismatched types on the macro's parameters (int to char *) or some such thing.

    Read the article

  • staying within boundaries of image?

    - by codefail
    So I am to loop through copyFrom.pixelData and copy it into pixelData. I realize that I need to check the conditions of i and j, and have them not copy past the boundaries of pixelData[x][y], I need another 2 loops for that? I tried this, but was getting segmentation fault.. Is this the right approach? void Image::insert(int xoff, int yoff, const Image& copyFrom, Color notCopy) { for (int x = xoff; x < xoff+copyFrom.width; x++) { for (int y = yoff; y < yoff+copyFrom.height; y++) { for (int i = 0; i<width; i++){ for (int j = 0; j<height; j++){ if (copyFrom.pixelData[i][j].colorDistance(notCopy)>20 ) pixelData[x][y]=copyFrom.pixelData[i][j]; } } } } }

    Read the article

  • Qt Creator Debugging

    - by CJ
    I'm using QT Creator on 3 platforms to create platform independent software. However, I'm getting a segmentation fault with the exact same code in Windows only. That doesn't sound so bad because I can use the debugger. Except, no matter how many breakpoints I set or where I set them, they are ignored by the debugger. I am 100% sure that my control flow is going through the breakpoint but not breaking the flow. Any thoughts? How can that happen?

    Read the article

  • What's the bug in the following code ?

    - by Johannes
    #include <iostream> #include <algorithm> #include <vector> #include <boost/array.hpp> #include <boost/bind.hpp> int main() { boost::array<int, 4> a = {45, 11, 67, 23}; std::vector<int> v(a.begin(), a.end()); std::vector<int> v2; std::transform(v.begin(), v.end(), v2.begin(), boost::bind(std::multiplies<int>(), _1, 2)); std::copy(v2.begin(), v2.end(), std::ostream_iterator<int>(std::cout, " ")); } When run, this gives a creepy segmentation fault. Please tell me where I'm going wrong.

    Read the article

  • quick sort problem

    - by farka
    I use qsort from C libary and I have datatype Element_type **pElement and Element_type is struct typedef element_type {int ,char ....} example, and i call quicksor function with qsort(*pElement,iCountElement,(size_t)sizeof(Element_type),compare); and callback function static int compare(const void *p1, const void *p2) { Element_type *a1 = (Element_type *)p1; Element_type *a2 = (Element_type *)p2; return ( (a2)->iServiceId < (a1)->iServiceId ); } but I always get segmentation fault. Why?

    Read the article

  • Assigning unsigned char* buffer to a string

    - by CPPChase
    This question might be asked before but I couldn't find exactly what I need. My problem is, I have a buffer loaded by data downloaded from a webservice. The buffer is in unsigned char* form in which there is no '\0' at the end. Then I have a poco xml parser needs a string. I tried assigning it to string but now I realized it would cause problem such as leaking. here is the code: DOMParser::DOMParser(unsigned char* consatData, int consatDataSize, unsigned char* lagData, int lagDataSize) { Poco::XML::DOMParser parser; std::string consat; consat.assign((const char*) consatData, consatDataSize); pDoc = parser.parseString(consat); ParseConsat(); } Poco xml parser does have a ParseMemory which need a const char* and size of data but for some reason it just gives me segmentation fault. So I think it's safer to turn it to string. Thanks in advance.

    Read the article

  • Allocating memory for a array to char pointer

    - by nunos
    The following piece of code gives a segmentation fault when allocating memory for the last arg. What am I doing wrong? Thanks. int n_args = 0, i = 0; while (line[i] != '\0') { if (isspace(line[i++])) n_args++; } for (i = 0; i < n_args; i++) command = malloc (n_args * sizeof(char*)); char* arg = NULL; arg = strtok(line, " \n"); while (arg != NULL) { arg = strtok(NULL, " \n"); command[i] = malloc ( (strlen(arg)+1) * sizeof(char) ); strcpy(command[i], arg); i++; } Thanks.

    Read the article

  • C pointer initialization and dereferencing, what's wrong here?

    - by randombits
    This should be super simple, but I'm not sure why the compiler is complaining here. #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int *n = 5; printf ("n: %d", *n); exit(0); } Getting the following complaints: foo.c: In function ‘main’: foo.c:6: warning: initialization makes pointer from integer without a cast I just want to print the value that the pointer n references. I'm dereferencing it in the printf() statement and I get a segmentation fault. Compiling this with gcc -o foo foo.c.

    Read the article

  • I need to create a very large array of bits/boolean values. How would I do this in C/C++?

    - by Eddy
    Is it even possible to create an array of bits with more than 100000000 elements? If it is, how would I go about doing this? I know that for a char array I can do this: char* array; array = (char*)malloc(100000000 * sizeof(char)); If I was to declare the array by char array[100000000] then I would get a segmentation fault, since the maximum number of elements has been exceeded, which is why I use malloc. Is there something similar I can do for an array of bits?

    Read the article

  • A pointer member variable having different values

    - by Rohan Prabhu
    Ok, to begin with, this is my code: HyperSprite::HyperSprite() { _view = 0; } void HyperSprite::publish(QGraphicsView* view) { _view = view; } void HyperSprite::getKFrame() { if(_view != 0) { qDebug()<<(void*)_view; } } Now, if I call HyperSprite::getKFrame() from within main(), I get the output: 0xbf8ffb84 I have a TCP server, which requires this QGraphicsView* variable. So whenever a new connection is made, HyperSprite::getKFrame() is called. However, whenever I make a connection to my server, this is the output: 0x1e425ff I honestly don't understand this. Shouldn't the value of a member remain same throughout? Why is the pointer value changing? As is obvious, whenever I try to use the _view pointer to access any of its members, a Segmentation Fault occurs. I tried using QSharedPointer, but it also results in the same problem. The data of the QSharedPointer automatically changes. Why is this happening?

    Read the article

  • Would it be possible for web browsers to automatically update rendering engines?

    - by unknowing
    As a way to prevent the major annoyances of browser segmentation and older versions. This way the code would only need to be done for the latest version of the browser, but users could still have the functionality of the older version and not be forced to do major updates? I am sure there will be some major flaws in this, and I would like you to tell me what they are! -Obviously, people may not want this as often auto-updating is frowned upon, however Chrome does it (or at least, they used to); Without a manual check, Chrome will update itself automatically, Google said. "Google Chrome will automatically checks for updates approximately every five hours. If an update is available, it will be downloaded and applied at the next browser restart," Google said. -there is still the problem of getting users from the really old ones onto the any new browsers that have this functionality -To prevent exploits in terms of updates, maybe they could have a 7 day opt-in period before being pushed out to everyone?

    Read the article

  • perror() give seg. fault

    - by Jack
    After an error occurs, I call perror(), naturally. But I'm getting a segmentation fault when I do this or printf("error: %s\n", strerror(errno)); I have no idea what is happing. int fd; if((fd = open(FILENAME, O_RDONLY)) == -1) { perror("fbi"); exit(1); } for(;;) { readed = read(fd, buffer, BUFSIZE); if(readed == 0) break; if(readed == -1) { perror("fbi"); // <- here's the error exit(1); } How to fix this?

    Read the article

  • pygame parachute

    - by user1473612
    I am using GUI2Exe to compile my python/pygame, game to a .exe I have a problem with the font module. using python 2.7 and the py2exe option in GUI2Exe I have updated python, pygame and py2exe with the 2.7 versions. My program runs fine but after I compile it with py2exe I get this. Here is the error I get: Fatal Python error: (pygame parachute) Segmentation Fault This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. My game starts off as a console and that part runs. But as soon as the display starts I get the crash. Thanks

    Read the article

  • Why is this simple hello world code segfaulting?

    - by socks
    Excuse the beginner level of this question. I have the following simple code, but it does not seem to run. It gets a segmentation fault. If I replace the pointer with a simple call to the actual variable, it runs fine... I'm not sure why. struct node { int x; struct node *left; struct node *right; }; int main() { struct node *root; root->x = 42; printf("Hello world. %d", root->x); getchar(); return 0; } What is wrong with this code?

    Read the article

  • The difference between delete and delete [] in C++

    - by Ilya Melamed
    I've written a class that contains two pointers, one is char* color_ and one in vertexesset* vertex_ where vertexesset is a class I created. In the destractor I've written at start delete [] color_; delete [] vertex_; When It came to the destructor it gave me a segmentation fault. Then I changed the destructor to: delete [] color_; delete vertex_; And now it works fine. What is the difference between the two?

    Read the article

  • strcat implementation

    - by skydoor
    I tried to implement the strcat by myself, and I found the strcat implementation from Wiki like this......but when I use it, there is segmentation fault. What's from with the code below? char * strcat(char *dest, const char *src) { size_t i,j; for (i = 0; dest[i] != '\0'; i++) ; for (j = 0; src[j] != '\0'; j++) dest[i+j] = src[j]; dest[i+j] = '\0'; return dest; }

    Read the article

  • Extract inputs from a pointer to array of characters in C / C++

    - by user2066884
    I am writing a command line utility but I cannot find a way to store the commands and arguments. so far I have the following but I get a Segmentation fault: int main(void) { char *command; char *args[MAX_LINE/2 + 1]; int should_run = 1; do{ cout << "cmd> "; int counter = 0; while(cin >> command) { strcpy(args[counter],command); counter++; } cout << args[0] << "\n"; } }

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23  | Next Page >