C :: Correct Way To Call A Function Within Main That Has File Pointer Parameters?

Mar 16, 2013

What would be the correct way to call a function within main that has file pointer parameters?

function prototype: Code: void CalculateBoth(int num1, int num2, int*sumPtr, int *diffPtr);

View 2 Replies


ADVERTISEMENT

C :: Passing Argument Of Incompatible Pointer Type - Warning In Function Call In Main

Jun 4, 2013

Code:
#include <stdio.h>
#include <stdlib.h>
int size_b_row1;
int size_b_col1;

[Code].....

View 2 Replies View Related

C++ :: Passing Arguments From Incompatible Pointer Type - Warning In Function Call Transpose In Main Routine

Jun 4, 2013

#include <stdio.h>
#include <stdlib.h>
int size_b_row1;
int size_b_col1;
int main(void) {
double C[4][4] = {{1,3,5,2},{7,6,2,2},{1,2,7,3},{2,3,5,3}};
double TC[4][4];
transpose(C, TC);

[Code] ......

View 2 Replies View Related

C :: File Opened In Main And Passing Pointer To A Function

Sep 14, 2013

I am getting a few compile errors for what might be a simple thing to do. I am opening a file in main, passing that pointer to a function and checking the contents of that file with a regex before I pass it on to build a BST. I am getting the following compile errors, what is wrong. Here are the errors:

Code:
gcc main.c fileCheck.c -o tree
main.c: In function `fileCheck':
main.c:19: error: syntax error before "FILE"
fileCheck.c: In function `fileCheck':

[Code] .....

Fatal error: Command failed for target `tree' Here is the two files and header that seem to be causing me the problems.

main.c

Code:
#include "main.h"
//#include "node.h"
int main(int argc, char *argv[])
FILE *fp;
if (argc > 2)

[Code] ....

And the header file.
main.h

Code:
#ifndef MAIN_H
#define MAIN_H
#ifdef __cplusplus
extern "C" {
#endif

[Code] .....

View 2 Replies View Related

C :: How To Call Function With Correct Arguments

Sep 13, 2013

I'm not a programmer, at least, not a good one. I'm a researcher and I need to implement this function and test it and use it for my research. I tested some clustering methods in JAVA and Matlab and also I want to test it on C. I don't know too much about programming, especially about C, I know nothing. I tried to implement some basic methods but I failed.

It's all about K-Means Algorithm. I'm working on a disease and I'm trying to find ways to early diagnosis. Anyway, these are details. The thing is, I found a 'free to use' function but I don't know how can I use it. I tried to learn something from Net, I downloaded a compiler, I paste the code and I get many errors... And I heard that I have to do some "calling function" stuff but I don't know how to..

The code is in the link below: URL....It's not imperative that using this function, it can be another one but it had to written in C.

View 13 Replies View Related

C++ :: Header And Prototype Correct But No Matching Function For Call To?

Dec 10, 2014

For whatever reason, I get an error meassage about lines 53-57 saying there is no matching function to call to. Yet the header and the prototype are correct (I think anyways).

#include <iostream>
#include <string>
#include <fstream>
#define N 10
using namespace std;
class cust{

[Code] ....

View 5 Replies View Related

C :: Return A String To Then Call It On Main Function?

May 26, 2013

I'm trying to return a string to then call it on main function.

Code:
const char* coiso(int chave){
char str [50];
sprintf(str,"%d",chave);
char txt[50] = ".txt";
strcat(str,txt);
return str;
}
int main () {
const char* info = coiso(8);
printf("%s",info);
}

If I do a printf("%s",str) in coiso function it works but the following code doesn't work.

View 10 Replies View Related

C++ :: Allocate Memory In A Function And Call From Main

Aug 30, 2013

So my assignment is to create a program that calls for a function in main that dynamically allocates an array[3] and then have pointers with multiple levels of indirection and pass them by reference so they are not lost after the function. Here is my code:

#include <iostream>
#include <array>
#include <iomanip>
#include <string>

[Code]....

Next part is to ask user for two non-negative numbers and then get the length of those numbers and create an array. for the size of each number they input. Then to separate those numbers and add the cross-sums.

View 6 Replies View Related

C++ :: How To Add A Call Function After Main Display Loop

Apr 29, 2013

How to ADD a call to the FindMostExpensive function AFTER the main display loop, and use the index returned to display the information about the most expensive car?

// Session7.cpp : Defines the entry point for the console application.
//using struct
// reading from file
// using functions

#include "stdafx.h"
#include <iostream>
#include <iomanip> // only used to tidy up the console output here
#include <fstream> // added file handling

[Code] .....

View 1 Replies View Related

C/C++ :: Program Crashing On A Function Call In Main?

May 5, 2014

i have this program I am working on and it seems to crash after the function call getdata()

here is the code

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

[Code].....

View 1 Replies View Related

C :: Create Array Of Integer - Function Call In Main

Feb 2, 2015

I'm writing code to create an array of integer and let user input choice to display, replace, add new element, etc.I created a header file in the header file there's a function:

Code:

int display_one_element(int* array, int num_of_elements, int position) {
if(num_of_elements < position || position < 0) {
printf("Position out of bound.
");
return 1;
}
return array[position-1];
}

in main I write a function call:

Code:

display_one_element(array, *p_num_elements, position);

My code seems to work fine but there's an error message right next to my function call:
1.too many arguments provided to function like macro invocation
2.Expression result unused

I tried to move the function from header file to c source file. but other functions in the header file works fine and this doesn't work with the error message.

View 3 Replies View Related

C++ :: Identify Correct Function Pointer From Vtable?

Jan 21, 2013

We know that function pointer for virtual function are stored in a vtable.When we have multiple function pointer entry in vtable and we call one of the virtual function then how the corresponding or correct function pointer is retrived from Vtable? Who do this stuff? In assembly code i can not see any code or logic to detrmine the correct function pointer.

View 4 Replies View Related

C++ :: Call Of Non-function In Function Main

Feb 16, 2013

I am getting call of nonfunction in function main <> error and 's' is assigned a value that is never used in the function warning...

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
float a,b,c,s,area;

[Code] ....

View 3 Replies View Related

C++ :: Pointer Function - Getting Information Back To Main

Feb 6, 2014

I am trying to make a information to pointer function but the problem is how/what number am i putting in for *a...

And can i get that information back to main? and is that right way to split the array in to ? because i have will 200 random number and I need to find the smallest and second smallest element in array.

two_smallest (print, size3,size3,size3,size3);
} void two_smallest (int find_array[] , int size3, int *a, int *a2, int *b,int *b2) {
for (int index = 0; index <= 100; index ++) {
if (find_array[index] < find_array [0]) {
find_array[0] = find_array [index];
*a = find_array[0];

[Code] ....

View 1 Replies View Related

C/C++ :: Converting Int To Double Pointer Outside Main Function

Dec 22, 2014

I have int pointer called p and i want to calculate average.Since average involves using double or float so i am trying to convert this in the function averagetemp. It still gives me an error saying "cannot be converted"...

#include <iostream>
using namespace std;
int* createArray(int n);
int lowesttemp(int *p,int f);
int highesttemp(int *p,int f);
double averagetemp(int *k,double f);
void print(int *p,int lowest_temp,int highesttemp,int average_temp);

[Code] ....

View 8 Replies View Related

C/C++ :: Assigning Pointer (int) Located In Main With Another Function

Aug 2, 2014

I have the following:

int Allocate(int, int *);
main() {
int *Pointer;
int Elements = 25;
// this works just fine - as expected.
Pointer = (int *) malloc(Elements, sizeof(int));
// This DOES NOT - The value of Pointer never changes.....

[code]....

View 2 Replies View Related

C/C++ :: How To Get Formation From Pointer Function To Main Function

Feb 13, 2014

int example (int [], int, *int,*int,*int,*int);
int main () {
My code will be here
example (int array[], int size, &a,&b,&c,&d); // Like this??? I try it didnt work

[Code] ....

View 2 Replies View Related

C++ :: How To Call A Thread By A Function Pointer

Nov 24, 2014

How to call a thread by a function pointer?

I get "error C2059: syntax error : '(' " on the indicated line.

Code:
#include <windows.h>#include <iostream>
using namespace std;
DWORD WINAPI Thread() {
cout << "ok" << endl;
return 0;

[Code] ....

View 9 Replies View Related

C++ :: Pointer Usage To Base Class Object In Vector Int Main Function

Aug 12, 2013

I know what are pointer's and how to use them but there is one point i am not able to understand. Below is the example code

I understand everything in the below code except 1 thing why i am using pointer to base class object in vector int the main() Function?

Code:
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
// base class

[Code] ...

Here is the lines of code i want to understand.

Code:
vector<Employee*> employees;
employees.push_back(&emp1);
employees.push_back(&mgr1);

I know if i will not use the pointer base class function "virtual double grossPay" will be called for both base class object and derived class object and when i will use pointer with reference to the object because base class function is virtual it will look for same function in derived class and if available it will execute it.

View 3 Replies View Related

C++ :: How To Call A Function With Multiple Pointer Arguments

Nov 3, 2013

In my code, I have a function like such: int function1(int* a, int* b). I am wondering how to call it in int main.

View 3 Replies View Related

C++ :: How To Call The Function In Different File

Sep 1, 2013

How to call the function in different file. 1 main and 5 function.

I'am not sure to create the function to call each by one in different file.

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

[Code] ....

View 5 Replies View Related

C++ :: Difference In By Referencing And By Pointer In Parameters?

Aug 6, 2013

void func(float arg); // arg is supposed to be in type, with no referencing, just a copy of it

void func(float &arg); // arg is supposed to be in, out type, with something contained in it already

void func(float *arg); // arg is supposed to be in-out type, with nothing contained in it already and can be NULL

void func(const float& arg) // arg is supposed to be in type, with nothing contained in it already and cannot be NULL

Am I all correct?

View 2 Replies View Related

C++ :: How To Call Class Method / Function From HXX File In CPP File

Feb 11, 2014

How do I call a class method which is defined in a .hxx file separately to a .cpp file? Is it any different from how we normally do it (using the scope resolution operator after the class name and then the method name with parameters) ?

View 1 Replies View Related

C++ :: Class Member Functions With Pointer Parameters?

Jan 30, 2013

Here is the assignment: (3pts) Given the following class header file, write the class’ source code for each of the accessor and mutator functions listed. (How the functions have listed their parameters, varying between passing by reference and by value.) Don’t forget to comment your code – it counts!

class Album {
private:
char * artist; // band or singer’s name
char * title; // title of the album

[code]....

The input will be an array. My questions: First, am I on the right track?

When using (char * a) for a function, for example, this is passing the address of a, correct? so then *artist=a; changes what the address of a points to?

also, the functions are bool when I would expect void. Why? for all of the set_" " functions, the parameter is *... but for set_record_label it is *&. That appears to be a mistake to me. Is that right?

what is the difference between *& and * as parameters?

View 5 Replies View Related

C++ :: What Is Function Call Overhead And Function Call Stack

Apr 25, 2014

What is Function call Overhead and Function Call Stack?

View 2 Replies View Related

C/C++ :: Read From File / Assign As String And Call Function As Argument

Oct 29, 2014

I try to use passing function as argument but I'm stuck. I have two questions: First, I try to call uppercase and open .txt in tfm Second, How can I read characters from in.txt as string and assign to char content[] ?

#include <stdio.h>
void tfm( char str_filename[], void(*pf_convertion)( char content[]));
void uppercase(char content[]); //converts all letters to uppercase
int main(){
puts("-------------------------------");
printf("tfm:
");
tfm("in.txt", uppercase);

[Code] ....

View 2 Replies View Related







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