C :: Delete A File When Function Is Called And Starts Its Loop

Apr 24, 2013

I have a function and i want to delete a file when the function is called and starts it's loop i have used this code but unfortunately the file is not deleted ?

Code:
void evaluate(void) /*evaluate the population */{
int mem;
int i;
double x[NVARS+1];
char buffer[101] = {"save.txt"};

[Code] .....

View 7 Replies


ADVERTISEMENT

C/C++ :: Linked List Delete Function Freezing Program When Called

Aug 12, 2014

My program seems to be working fine, except for when I call on my delete function. I don't receive any errors, but when I call the delete function my program outputs nothing and freezes. As in, my print function (which is called before the delete function) doesn't even work. I've tried removing bits of the function to see if I could pinpoint where exactly the issue is, but I've had no luck.

#include <iostream>
#include <string>
using namespace std;
class List{
private:
struct node{
string _data;

[Code] ....

And the function that is causing me trouble:

void deleteNode(string data){
node* del = NULL;
t = h;
n = h;
while(n != NULL && n->_data != data){

[Code] .....

View 5 Replies View Related

C++ :: Function In One Src File Called From Code In Different Src File - Linker Error

Mar 27, 2015

I have a function in one src file called from code in a different src file.

In ig_cfunc.cpp

Code:
#include "ig_tools.h"
int x2_count = 0.0;
float rel_branch_degree_tmp = 0.0;
string type;
vector<int> is_disp_type;

[Code] ....

I am getting a linker error,

Code:
ig_cfunc.cpp:1609: error: `calc_rel_branch_degree' undeclared (first use this function)

I have deleted all of the objects and recompiled to make sure that everything is in sync. I can't see what the issue is here and I'm not sure what to do next. This code actually worked until I changed the name of the function, so the types are all correct and such. This is the format I use for all external functions ....

View 1 Replies View Related

Visual C++ :: Loading A File And Indexing Line Starts

Jun 14, 2013

I've spent some time trying to performance test various methods of loading / accessing a file, either into memory or through a memory mapped file, but I am having some trouble.

FILE * pFile;
std::ifstream ifs;
MapViewOfFile

I'm have trouble because Windows appears to cache the file, so I am getting very mixed results. Sometimes a huge file (100's MB's) will load quickly, other times almost instantly.

How to stop Windows from doing whatever it's doing, so I can see the real time taken to load/access a file from disk?

View 8 Replies View Related

C/C++ :: How To Create Function To Delete Record Of Binary File

Aug 17, 2013

I want to create a function to Delete , Edit record of Bianry File in C++, I have tried again and gain but not success .

View 1 Replies View Related

C :: List - Why Delete Function Doesn't Delete

Dec 9, 2014

I have to manage a Clinic. I need to delete a booking (for example, if John said he's coming on March 22nd at 15:30 but then he say he's not going to come, I have to delete that booking so another person can use it).

idSearched: the id of the person that is not going to come. I have a lot of specialties and each one has a list. So I ask for the speciality to delete the node (the node contains John's booking). If I don't find it, I return (-1). searchSpecByID return a pointer to the list where the speciality is. So head will point to the first node of the list. In nodeToDelete I have the node I want to delete.

The program detects OK when is the first in the list and when not, but it doesn't delete the node.

Code:

typedef struct bookingList{
tSpecialty specialty;
struct nodo* intro;
} tList;

[Code].....

View 7 Replies View Related

C++ :: Keyboard Function That Is Called In Main Function To Make Shape Move

Jan 19, 2013

Ok so I am working on a game and I'm in the process of developing my Player class. Anyways, what I have is a keyboard function that is called in my main function to make a shape move.

void myKeyboardFunction(unsigned char key, int x, int y) {
switch ( key ) {

[Code].....

But when I try to call it, trying to copy my previous method,

glutKeyboardFunc(Player1.playerControls);

I get an error

error C3867: 'Player::playerControls': function call missing argument list; use '&Player::playerControls' to create a pointer to member

I get an error saying it can't convert parameters. I would just like to understand why the arguments become a problem when I make the function a member of my class, when the first method I used is so easy.

View 2 Replies View Related

C++ :: How To Have A Function Be Called Every Second

May 4, 2013

I am working on this project where I need a function to be called every second. At this time, I am thinking that I have to create a thread but I am clueless on how it will get called every second.

View 5 Replies View Related

C :: Reverse A String - Function Is Not Getting Called

Aug 29, 2013

I am new to C and trying to reverse a string but the function is not getting called.. the console says :

Enter a stringabhi
bash: line 1: 229 Segmentation fault (core dumped) ./program

Code:
#include<stdio.h>
#include<math.h>
#include<string.h>
char* reverseString(char input[]);
void main()

[Code] ....

View 6 Replies View Related

C++ :: Base Class Function Gets Called

Oct 26, 2012

Here are the classes:

BaseClass.h

Code:
class BaseClass {
public:
BaseClass();
virtual ~BaseClass();
virtual void printStuff() const;

[Code] ....

When I call printStuff, the DerivedClass's function gets called. Now, if I remove the const part from the DerivedClass's printStuff function, we call the BaseClass's printStuff function.

View 4 Replies View Related

C++ :: ROS Subscriber Callback As Member Function Does Not Get Called

Feb 27, 2015

There is already a thread with exactly the same problem I have, but the answer to solve the problem isn't stated at the end. Problem with callback as classmember.

View 4 Replies View Related

C :: Create Function That Is Then Called To Calculate Powers

Nov 11, 2014

As I am taking my first steps in C, I study K&R (I guess most of you did the same, right?)

In the introductory chapter about functions (1.7) there is an example showing how to create a function that is then called to calculate powers (b**n). I simplified it to calculate only one given power, 2**5:

Code:

#include <stdio.h>
int power(int m, int n);
main() {
printf("%d", power(2,5));

[Code]....

It will then be called to make the calculation in the above string.

First things first: we already know how to use while(getchar!=EOF) to count characters (K&R chapter 1.5.2) but what if -instead- the input is a specific string? How to "read" it and how to tell my program that the string is finished? And most important: "reading" will be done in the function or in the rest of the body?

View 1 Replies View Related

C++ :: Error - Reference To Non Static Function Must Be Called?

Feb 27, 2013

So on lines 36 - 39 (The commented out functions) is where I'm sure is causing this error because once I don't comment them out pretty much everywhere Flink or Rlink is used or defined I get this error.

#ifndef nodes_Nodes_h
#define nodes_Nodes_h
#include <cstdlib>

[Code]....

View 4 Replies View Related

C++ :: Finding Size Of Array In Called Function

Nov 27, 2013

How to find the size of an array in called function? When we pass the array a argument to function definition we will be having base address of array, so my understanding is that we will not get the size of an array? but is there any hacking for this to find size of array other than passing as size an argument to this called function?

View 3 Replies View Related

C++ :: Write A Recursive Function Called Sumover

Mar 8, 2014

Write a recursive function called sumover that has one argument n which is an unsigned integer. the function returns double value which is the sum of reciprocals of the first n positive integers =.

for example sumover 1 returns 1.0
sumover 2 returns 1.5 like 1/1+1/2

View 11 Replies View Related

C++ :: Pure Virtual Function Called At Runtime

Jul 12, 2014

I'm currently making a game and what happens is that during runtime, it suddenly closes and a message is shown in the console saying "Pure virtual function called at runtime".

Here is the code: [URL]

The problem seems to occur somewhere between lines 662 - 695. And it seems to only happen when the size of the vector reaches 1.

View 2 Replies View Related

C :: Return 2 Values From A Called Function - Arguments And Parameters

Feb 2, 2013

Is there anyway we can return 2 values from a called function. Example

Code:
float xxxx(float a, float b, float c, float d)
{///
///
///
}

void xxx() {
int e,f,g,h;
////
////
xxx(e,f,g,h);
}

So if I want for example a+b and c+d, can i return those 2 answer? I don't think its possible since I am new into C programming.

View 5 Replies View Related

C++ ::  Class Safe Array Type Print Function Not Working When Called

Oct 22, 2013

I've created a function where you can choose any bounds for an array based list (positive or negative, as long as the first position is smaller than the last position). However for some reason when I call the print() function in my application program it doesn't do anything. My print function is technically correct (I still have work to do on the output) but I can't figure out why it wont show anything at all. Below is my header, implementation, and main program files, along with results from running the program.

Header File:

//safearrayType Header File
class safeArrayType {
public:
void print() const;
void insertAt(int location, const int& insertItem);
safeArrayType(int firstPlace=0, int maxPlace = 100);

[Code] ....

ResultsEnter the first bound of yourlist: -3(this was my input)
Enter the last bound of yourlist: 7(this was my input)

Press any key to continue...

View 1 Replies View Related

C++ :: Fractal Starts Zooming Out

Apr 11, 2013

I'm trying to zoom into a fractal and to do this I'm using mouse click to calculate where the centre should be and then taking away 1 from the right and top and adding 1 to the left and bottom to make a zoomed in version. This works perfectly... for 15 zooms. When the value of the left and right meet each other the fractal starts zooming out instead of in. Through multiplication maybe?

View 3 Replies View Related

C :: Loop Does Not Work And Program Quits Without Displaying For Loop Function

Oct 13, 2014

We are making a program--but every time we input a value for scanf, the following for loop does not work and the program quits without displaying the for loop's function. We are not getting any errors.

View 11 Replies View Related

C++ :: Simulate Random Walk That Starts With Position 0

Mar 19, 2014

I am supposed to create a program that simulates a random walk that starts with position 0. If its odd it moves to the right (add one) if the random number is even it moves to the left (subtract 1).

#include<iostream>
#include<iomanip>
using namespace std;
void main() {
int num1, num2, num3, num4, i, rs = 12345 ;
cout << " Please enter the number iterations to be executed: ";

[Code] ....

I'm getting an error when I try to run the program: error C2106: '=' : left operand must be l-value. So I don't even know if what I have is right.

View 19 Replies View Related

C++ :: How To Start Counting Time When Program Starts

Apr 7, 2013

I want to know if there is a function or library that starts counting time when the program starts. Because I'm making a program that is dependent on time.

Pseudo code

time starts
if ( seconds % 2 == 0 ) {
counter++;
}

View 2 Replies View Related

C/C++ :: Merging 2 Files Program Starts But Does Not Complete

Oct 9, 2014

I'm having an issue with merging two files. Basically, my instructor gave me pseudocode and two files to merge together. Each file (a male client and a female client file) has three names and id numbers inside. The finished MergedClients.rtf should have all six clients in ascending ID order. I wrote the C++ code and after combing through a couple times to fix a few errors, it finally ran. The problem is it starts the process, but it doesn't ever finish.

I tried changing some of the bool expressions thinking I mixed up the true and false parts. After that the program ran and it created the new output file, but the file was empty. So, I don't think I mixed any of those expressions after all.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
ifstream inFile1;
ifstream inFile2;

[code]....

View 10 Replies View Related

C++ :: How To Delete A Parameter In A Function

Apr 17, 2014

How I can delete a parameter in a function .

int *buildTrail(int antIndex, int start, double *pheromones) {
int *trail = new int[tabu];
bool *visited = new bool[tabu];
trail[0] = start;
visited[start] = true;

[Code] ....

If I comment all lines includes visited word , no exception occurs , Otherwise , exception throws.

Simply put , How can i delete visited parameter as long as its role has been finished?
.
.
.
delete visited ;
return trail;

View 4 Replies View Related

C++ :: Delete Function Not Working?

Oct 9, 2014

making my delete function work. My program does compile but my delete function doesn't work. I haven't finished my last two functions because I am focusing on the delete but how to Sell a title and print the value of all sold titles would be nice as well.

#include <iostream>
#include <cstdlib>
#include <string>

[Code].....

View 2 Replies View Related

C++ :: Generate Calendar For A Year - Day Of Week Month Starts From

Oct 18, 2013

So for my C++ class I am required to create a program that will "Write a program to generate a calendar for a year. The program should accept the year and the day of the week for january 1 of that year (0=Sunday, 1=Monday, etc.)" (problem statement) and I am completely stuck. I've posted what I have so far below:

#include <iostream>
#include <iomanip>
using namespace std;

bool isLeapYear(int year);
int daysInMonth(int month, bool lpYear);
int printCalendar(int month);
int printDay(int dow);

[Code] .....

View 3 Replies View Related







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