C++ :: Passing Unknown Arguments To Unknown Function

May 1, 2013

So I'm making setTimeout and setInterval functions.

I have this remember function (that is part of Timing class) which takes a function pointer and a void pointer, which are remembered in that object.

Another (timing) function of that object is called in every loop of the program and when specific time passes that function calls the remembered function whit the remembered void pointer as argument.

The problem is that the functions that need to be called require unknown multiple parameters, so what I need to do is make a new class that will store the needed arguments. I make the function that needs to be called and that storage object and pass pointers to them to my remember function, when the remembered function is called it stores the data from storage object in new variables and dose it's thing.

View 3 Replies


ADVERTISEMENT

C++ :: Matrix With Unknown Dimension?

Feb 18, 2014

I try to write code for one problem which is worked with the matrix.I have written in specific size 5 by 5 and I know the general formula for these matrix based on dimension,I want to write a general form that take the matrix size and then create my favor matrix.However,when I write like below the following error is appeared

int m;
cin>>m;
int A[m][m];

Error: m must be constant

View 2 Replies View Related

C/C++ :: Unknown Type Name PGconn

Feb 27, 2015

I have the following code

#include <stdio.h>
#include <stdlib.h>
#include <postgresql/libpq-fe.h>

[Code].....

View 2 Replies View Related

C++ :: Cin And Unknown Number Of Integers

Dec 2, 2012

i dont usually write console programs, and i cant seem to find out how one parses an unknown number of arguments with cin.

the program receives an unknown amount of integers in stdin, and i need to parse them withouth hanging.

Unfortunately, stdin is a async. stream and blocks, if it doesnt find any integers left.

I cant use peek() or seek() either, as both are async, too, (which makes me wonder what their exact use is?).

View 3 Replies View Related

C :: Warning - Unknown Escape Sequence

Feb 2, 2013

I'm doing some file input/output work here in C and received this warning during compilation (GCC). My research indicates that this error is in response to white space or a character cancellation function or something like that. I'm not 100% sure exactly what it means. My code works fine, but the following warning does appear.

Code:
warning: unknown escape sequence: '40'

Here's my code (excluding a bunch of comments at the bottom of the file).

Code:
#include <stdio.h>
int main(void){
FILE *file;
file = fopen("Running Practice.c", "a");
fprintf(file, "Testing...
");
fclose(file);
}

I believe the error I received has to do with either the ' ' I used when appending text to my file, or something to do with there being a space in the file name itself.

View 6 Replies View Related

C :: Reading Files Of Unknown Size

Jan 23, 2013

I want my program to be able to read text files in the format:

number number
number number
number number...

and so on, so there are two columns of values. The problem I'm having is, there are a lot of numbers in the file, and it can vary. The program needs to read the numbers, put one column into one array, and the other in another, perform some operations on it all, and eventually pop out two different arrays. In other words, after I've got these arrays, I don't need them for much longer. I was hoping I could dynamically allocated some arrays to store the numbers and just free them as soon as I'm done with them.

If the file wasn't of such variable size or if it was guaranteed to be under a certain number of variables, I would have used:

Code:

while ( fscanf(input, "%lf %lf
", &col_1[], &col_2[]) == 2 )
{
no_rows++;
}

The problem is I want to allocate "no_rows" as the array size, which I don't have until after I have read the file.

View 9 Replies View Related

C :: How To Save Returned Of Unknown Length

Sep 15, 2014

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));

View 3 Replies View Related

C :: Masking A Bit String Of Unknown Size

Mar 2, 2015

I have an assignment where I am trying to get the frac bits of a IEEE number representation. The number of exp and frac bits are given as parameters from the main, but I am unsure what bit mask to use as a one-size-fits mask.

View 5 Replies View Related

C++ ::  split String (unknown Length)

Mar 27, 2013

I manage to split this str = "abc,def,123"

to s1 = "abc", s2 = "def", s3 = "123" with this piece of code using find and substr.

string str, s1, s2, s3;
getline(cin, str);
unsigned pos1 = str.find(",");

[Code] ....

But what should I do if the len of the string is unknown ?

For example, str = "abc,def,123,ghi,jkl,456,mno" and so on...

View 4 Replies View Related

C++ :: How To Use Multidimensional Array With Unknown Bounds

Feb 11, 2013

void printMatrix(int x[][]){
cout << "Matrix " << x << ":" << endl;
for(int r=0;r<rows;r++){
for(int c=0;c<colums;c++){
cout << x[r][c] << " ";
} cout << endl;
}
}

Error: declaration of 'x' as multidimensional array must have bounds for all dimensions except the first

How can i use multidimensional array with unknown bounds?

View 1 Replies View Related

C/C++ :: How To Define String Of Unknown Length

Mar 7, 2014

how to define a string of undefined length in c programming?

View 1 Replies View Related

C++ :: Read A String Of Unknown Length From Stdin

Oct 10, 2014

I want to read a string of unknown length from stdin. I tried to follow the approach from this link. URL....My code is like this:

#include <iostream>
#include <string>
using namespace std;
int n;
cin >> n;
cout << "The value of n is " << n << endl;
}

[code]......

What I have noticed is that if I take integer input from cin (cin >> n;) in the above code before getline, the control does not stop on getline to take str as input from the console. If I don't do (cin >> n) before getline then the control stops on getline and takes the string as input.What is the best way to read from console multiple strings of unknown length in combination with the integers?

View 5 Replies View Related

C++ :: Writing Calculations For Unknown Amount Of Students?

Jun 27, 2014

I need to create a program that continuously records data until the user enters '0'

The data that I read in is the student's last name, the year of the student (1-4), the major, the gpa, and the advisors name. I then need to print out how many students are in each year (1-4), the number of students each advisor has, the average gpa for each major, and so on. This is what I have, but I am stuck and think that I might be headed the wrong direction because the only thing working is the loop (not my gpa test calc).

//This program displays information pertaining to students
#include <iostream>
#include <string>
using namespace std;
int main () {
int studYear;
double average, studGpa;
string studName, studMajor, studAdvisor, complete;

[code]....

View 2 Replies View Related

C/C++ :: Unknown Type Error For Bool Keyword

Jun 24, 2014

Is the bool keyword in C exactly like the boolean keyword in Java? why this code is getting an 'unknown type error' when I initiialze looping.

#include <stdio.h>
#include <stdlib.h>
int main()

[Code].....

If I am completely using the boolean concept wrong in C, should I just use break statements instead?

View 11 Replies View Related

C/C++ :: Reading Unknown Number Of Integers In A Line?

Mar 1, 2015

I have a file with such a format:

string string 8 7 2
string string 7 12 19 -4
string string 1

As you can see I don't know how many numbers there are at the end. I have this code now:

while(!in.eof()) {
kr = 0;
getline(in, pavard, ','); getline(in, vard, ','); getline(in, gr, ',');
while(in.peek()) {
in >> k;
kr += k;
}
in.ignore();
}
in.close();

I tried various combinations with peek() function, but nothing worked.

View 2 Replies View Related

C/C++ :: Output Of Program Shows Unknown Character When It Run

Mar 20, 2014

#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
float CalcPriceMember1(int,float&,int&);
float CalcPriceMember2(int,float&,int&);
float CalcPriceNonMember1(int,float&,int&);
float CalcPriceNonMember2(int,float&,int&);

[code].....

View 8 Replies View Related

C++ :: Tile Map (unknown Reason For Unresolved External Symbols)

Nov 7, 2013

So I tried to make a tile map function to display my map as tiles. I keep getting unresolved external symbol errors, I've included the header file, and used every declaration in it, but to be completely honest this is mostly just a try to see if I could do it, and so far I'm failing. So if you can see why I'm getting the error.

header tileMap.h:

#include<SFML/Graphics.hpp>
#include<iostream>
#include<fstream>
#include<string>
#include<cctype>
#include<vector>

class tileMap{

[Code] .....

output message:
1234567891011121314
1
1> main.cpp
1>c:users wiggystardustdocumentsvisual studio 2010projects ilemapenginemain.cpp(21): warning C4018: '<' : signed/unsigned mismatch

[Code] ....

View 8 Replies View Related

C++ :: Reading Unknown Number Of Inputs And Adding Them In Vector

Jan 16, 2013

Consider the following piece of Code:

int ReadNumbers() {
int num;
vector<int> x;
cout << "Enter Numbers" << '

[Code] ....

The while loop is expected to terminate when the user provides an Invalid Input. But this while loop behaves unexpectedly when the user provides a 'Newline' input (by pressing Enter) and becomes an infinite loop. How can I prevent this from happening? Also I've heard that expecting invalid inputs isn't good code design. Is this true? If yes, then how can I solve my question without expecting Invalid Inputs?

View 10 Replies View Related

C++ :: How To Make A Program That Opens Unknown Files Extensions

Apr 6, 2013

Okay, so I think I have just passed the intermediate line in my skill of c++ and my question is how do I make a program that opens unknown files extensions. for example like .plr. Because I see a bunch of files for game modifications like that, that was a good reason I started c++ too.

View 4 Replies View Related

C++ :: Read All Values / Strings Form Unknown File

Nov 4, 2014

For an assignment I have to write a program which basically converts 8 bit binary numbers to ASCII and outputs the assembled text. Here's the catch:

The 8-bit binary numbers are provided by some external file (which only contains 8 bit binary numbers); the name and hence length is not known. The external file is called with a pointer upon execution

(./"conversion program" < external_file.in).

I'm getting the 8 bits as a string, calculate/convert decimals, output char type. HOW do I know when to stop the loop? If I just pick an insanely high number I get random stuff at the end; no boundaries obviousely lead to an infinite loop. Can I determine the lenght of this random ext file somehow nonetheless?

Is it possible to create a vector which dynamically adjusts itself until there are no more strings = end of the file?

View 6 Replies View Related

Visual C++ :: Default File Icon - Unknown Extension

Apr 1, 2013

If I don't assign the icon to my executable file (f.e. it's a DOS application), or I have some unknown extension in the file, Windows Explorer assigns the icon to this file.

Is there a way to somehow get this icon? Either from the registry or by any other means.

View 3 Replies View Related

C++ :: Deciphering Unknown Shifted Caesar Cipher Text File

May 25, 2014

The assignment is to open an encrypted file, count the occurrence of each alphabetic character in the file. find the highest occurring letter and use that to find the shift, then apply the sift to the file in order to decipher and then print out the deciphered txt.

#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main(){
string word;
ifstream txt;
int arr[26] = { 0 };

[Code] ....

View 5 Replies View Related

C/C++ :: 64bit Application Crashes Due To Unknown Memory Corruption In Linux

Dec 15, 2012

The application that I ported from 32 bit linux to 64 bit linux is crashing due to unknown memory corruption Also some time teh address is printed in 32 bit only as below

this=0x6787e0

any reason why this is happening?

View 1 Replies View Related

C++ :: Reading From Console Multiple Strings Of Unknown Length In Combination With Integers

Oct 10, 2014

I want to read a string of unknown length from stdin. I tried to follow the approach from this link.

[URL]....

My code is like this:

Code:

#include <iostream>
#include <string>
using namespace std;
int n;
cin >> n;
cout << "The value of n is " << n << endl;
string str;
getline(cin, str);
cout << "The entereed string is " << str << endl;

What I have noticed is that if I take integer input from cin (cin >> n in the above code before getline, the control does not stop on getline to take str as input from the console. If I don't do (cin >> n) before getline then the control stops on getline and takes the string as input.

What is the best way to read from console multiple strings of unknown length in combination with the integers?

View 1 Replies View Related

C/C++ :: Creating Program That Allows User To Enter Unknown Number Of Income / Expense Amounts

Feb 21, 2014

I'm trying to create a program that allows the user to enter an unknown number of income and expense amounts. The program has to us see a while loop and display the income total, expense total, and total profit or loss. I've got it really close, but I'm doing the loop wrong. It counts the sentinel value (-1) towards the total, instead of just ending like it is supposed to.

#include <iostream>
using namespace std;
int main() {
//declare variables
double incomeInput;
double expenseInput;
double incomeTotal=0;
double expenseTotal=0;

[code]....

View 5 Replies View Related

C++ :: Read Unknown Number Of Integer Values And Then Print Count Sum And Average Of Odd Values

Apr 9, 2014

write a c++ program that reads an unknown number of integer values and then print count, sum and average of odd values, even values, positive values, negative values!!

View 1 Replies View Related







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