C++ :: Random Crashes With Process Returned -1 (0xFFFFFFFF)
Jun 30, 2013
I randomly get this when I execute my program. Sometimes it happens three times in a row sometimes it can go about 10 times before it shows up again.
I was not able to find out what the error code means, and I can't pinpoint the error. During debugging it NEVER happens, and logging tells me it happens between two cout << operations.
I have an application that reads a process and return values from it. The problem it works fine with small processes but i have some processes that are about 1GB or even 2GB and when i try to read such big processes the application crashes. I'm trying to find a way to read the process memory in chunks of maximum 10 MB. The read code looks like:
I having some issues with two different programs here... One of them crashes and returns random negative numbers whenever it reaches a "fscanf" function and the other displays a "Polink fatal error: access denied" error.
I thought the reason this kept crashing before was because I didn't type the data into the text file it was writing too correctly, but I made another program to do that, and it crashed whenever it got to fprintf. Program works perfect besides the file stuff...
I am working on my final project for my class and after finally getting it to compile with no errors to finding examples/tutorials and following skeleton code I cam encountering a problem.
The program runs, asks all the correct questions but when it displays the base pay and total pay for all 3 employees it comes back as ( -1.0743 blah blah )
When they work over 40 hours it works correctly but when they work under 40 hours it displays those weird numbers in those sections.
// Kevin Johnson -- Overtime Pay -- Final Assignment // Created 11/14/2013 // Edited 11/17/2013 #include "stdafx.h"
Why is it not okay to return void? Most compilers will probably let you (gcc does) but it gives you a warning that you aren't supposed to. Most languages allow you to return void.
Something like
Code: void log(const std::string & txt){ std::cout << txt << std::endl; } //C++ way to do it void bar(int i){
I have this int type function that returns a number. It returns the value 2 for now but later it will return more variety of values. How do I use the value it returned? I'm not sure of the proper syntax.
Code: #include <math.h> #include <stdio.h> int main(void) { float a,b,c,root_1,root_2; printf("Please enter value a from the quadratic equation
[Code] ......
And I keep getting this error:
Code: /tmp/ccgtUIun.o: In function `main': assign345.c:(.text+0xc7): undefined reference to `sqrt' assign345.c:(.text+0xef): undefined reference to `sqrt' collect2: ld returned 1 exit status
I've had with visual studio but nothing seems to be working. No matter what I do even with simple programs, like Hello World, I'm always getting an error about a .pch header file.fatal error C1083: Cannot open precompiled header file: 'DebugConsoleApplication1.pch': No such file or directory
This is only for one of the programs I've made but I'm pretty new to programming and I've not even used the header files for anything so I have no clue how to resolve this problem.
I have some struct which contains: void *elems (basically a pointer to an array of contiguous memory).
I want to use bsearch to return a pointer, and then somehow figure out where in the array that value is. Having a pointer in this case isn't enough, I need to know what the index is. I've tried a number of things:
int index; void *value = bsearch(key, start_ptr, cv->count, cv->elemsz, cmp); index = &value - &start_ptr; return index; [ Replacing the second line with:
// in the first instance index = (char*) value - (char*) start_ptr;
// in other instances... index = ((char*) value - start_ptr))/cv->elemsz)
I call a function that returns a string, and I can print it out fine, but I want to test the result of the function to see if it returns 0. But I can't just call the function again (GetNextToken(b)) because it will generate a different token. I can't allocate space for the string because I'm not sure what the size of the returned string is going to be.
Basically I want to see if the GetNextToken(b) returns 0, and if it doesn't then print the string. And running GetNextToken(b) again will give a different result.
Code: int main(int argc, char **argv) { SomeStruct* b = CreateStruct(argv[1],argv[2]); printf("HERE %s", GetNextToken(b));
So, I'm in the midst of implementing my own malloc() and free() functions, but I'm having a hard time with the syntax of getting the address that malloc returns. Whenever I check the address, it's 0 Here's the code:
Code: char *word = malloc(10); int address = *word; printf("%d",address);
The reason I want the address is so that I could store it in a data structure for further usage when I'm dealing with different cases for the free() function. Or is there another way to do this?
What does the C++ standard say about returned temporal objetcts's lifetime ?For example, in this code:
#include <iostream>// Object cout, manipulator endl using std::cout; using std::endl; class C { private:
[code]....
Here, the temporal object C returned by function f() still lives when function h() is called and is destroyed inmediately after function h() returns to his caller (the function main()). So, it seems that a returned temporal object lives while it is used and it is destroyed when not used (in the next sentence of the sentence that call the function that returns the temporal object). Does the C++ standard specify that this must be the behaviour of C++ compilers?
I want know if the query returned zero rows or not.
Don't want to use count(*)
sql = "select * from TABLE where employeefirstname = @First order by EmploymentStatusDescription"; using (SqlCommand cmd = new SqlCommand(sql, conn)) { cmd.Parameters.AddWithValue("@First", First); reader = cmd.ExecuteReader(); } while (reader.Read())
I am just trying to make a simple two player game. First player enters the movie and second player guesses it by using some basics of C++.
movie[] = entered by player 1. movie_temp[]= a temp array with '_' in it. It updates after every guess by player 2.
MY PROBLEM: Please refer the main function where I called the function movie_check().
This updates the life after every guess. I want the same to happen for my movie_temp array.
When i run this program, only the lives are updated properly, on correct guess the lives are not reduced, but in next turn the array_temp is not updated and the same array is displayed again and again after each gas.
How to create a function which return array and save it in movie_temp (just as I did for life).
I need to get the current time, have the system sleep for a period of time, then return the difference in seconds.
#include <iostream> #include <string> #include <ctime> #include <time.h> #define _CRT_SECURE_NO_WARNINGS using namespace::std; // in the <ctime> library is a function time(0)
[Code] ....
I'm not receiving an errors but the return value is not correct. It's returning 1.4259 no matter how long it sleeps for.
What is the programmers responsibility with respect to const char * returned by various functions, like the C++ string class c_str() function which returns a const char * to an c style string array? In VC++ I cannot delete a const char * which holds a string literal. Take the following code for example:
Code: void func() //a useless function with illustrative code { string s1("abcd"); string s2("efgh"); const char * cc1 = s1.c_str(); //c_str() returns a const char * c style string pointer s2.c_str(); //this returns a const char *, which must be allocated on the heap right? delete cc1; //produces run time error in Release mode in VC++ }
The problem with the above code snip is that space is allocated on the heap (or so I believe) for the const char *'s returned by the 2 calls to c_str(). The delete attempt fails and there is no opportunity to delete the space allocated by const char * because its not assigned to anything (however I see c_str() used this way extensively)
So, if I cannot delete a const char *, how does the memory get recovered? Perhaps the string objects s1 and s2 themselves have pointers to the items on the heap made by c_str() calls and they get deleted by the destructors of s1 and s2 when the function ends?
I'm new to C++ and keep getting an error. I get a permission denied and id returned 1 exit status, the code is fine and as far as i understand this would be because my OS doesn't allow modification of currently running files which would make sense as when i look in task manager it shows my program running even though it has finished. Ending process/process tree does nothing as does using any third party process terminator.
There is no loop in the program or anything even a simple hello world program yields the same result. Only way i can re-run my program is restarting my computer or saving the project under another name and re-compiling...
c++.....in my program i have 3 string-s (string houses,string ink,string buildings)and i must add function substr()... In the program i need to add a function that receives a parameter of type string. The task function is that the resulting string is inserted characters '=' to split a string of characters into subsets 5 letters long. If you come to the end and no more letters after the equal sign is not added. The function should not display anything but the resulting string is returned as a result. Example:
A function recive: "housesinkbuildings" .The function returns: "house=sinkb=uildi=ngs" in The main program Add call of this function so that it is specified as a parameter string consists houses,ik, buildings.
This has happened before, when I try to run a code it will say "blah.exe has stopped working" and I would have to change the code in some way to make it work.
In my program, I am trying to implement a set in which I can add/remove and print, it doesn't have to be a specific value removed just that it removes an item from the list. When I call the removeItem function it crashes, saying my iterator is out of range. I don't understand what is wrong. Here is my code:
I've implemented a records system for a college assignment and everything works as intended. However upon increasing the amount of records to store in my array above 10, the program crashes upon adding a new employee and I can't work out why...