C++ :: Error Entering A Function?

Jul 2, 2013

I have no error compiling, but running my project it stops before entering a function and debugging I have an error about Segmentation fault. The function:

Code:

Mat logGabor(matriz filter,Mat filter,double r_o,double theta_o,double sigma_theta,
matriz radius,matriz theta,int cols,int rows,double sigma_r,int *padSize){
Mat rpad;
int k=*padSize;
printf("Welcome to the function"); //Here the error
...

More info: I created the matriz as : typedef double** matriz;
and a createmat function that give back a double** and in this function I allocate space for matriz and works. In the main:

Code:
Mat chr-Rpad[4][5]; //chrOrient=4;chrScales=5
for(int i_or=1;i_or<chrOrient;i_or++){
for(int i_sc=1;i_sc<chrScales;i_sc++){
//some math calculation
chrRpad[i_or-1][i_sc-1]=abs(logGabor(filter,imftt2,r_o,theta_o,sigma_theta,radius,theta,cols,rows,sigma_r,padSize));

View 6 Replies


ADVERTISEMENT

C++ :: Entering Valid User Input?

Mar 19, 2013

How can I write my simple program so if the user enters an invalid number, The program won’t exit? I know I am supposed to use a if (cin) or if (!cin),

But I don’t know where in the program or how I should use it. Right now my Program looks kind of like this:

If (number > 1 && number < 1001)
Go through some function loops
Else
Cout << “invalid number”;

I need to write it so when the user enters an invalid number, the program would Keep asking for the right number until it's given.

View 1 Replies View Related

C :: Entering Characters Into A String Pointer

Feb 8, 2013

1. The debugger shows that the characters are entered into the word pointer, and when a punctuation or space character is encountered, I terminate the string with a ''. But when I use puts to print the string, garbage is printed. Why is this?

2. Also, if I don't allocate memory for word the compiler gives a warning about it being used uninitialised. But I didn't allocate memory for the array of pointers(words), and the compiler didn't give any warnings. Whats the difference between a pointer and an array of pointers?

Code:

// wordcount.c - count words.
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

[Code]....

View 7 Replies View Related

C :: Way For User To Stop Entering Values

Mar 6, 2015

Code:
#include <stdio.h>
#include <stdlib.h>
/*

You are to write a program that will allow a user to enter infinite numbers (greater than zero)(One number at a time). You must have a way for the user to stop entering values.Once the user stops, you will immediately display the following:

The lowest number entered is:
The highest number entered is:
The number of values entered is:
The average of the numbers entered is:
*/

main() {
int userNumber=0, sum=0, count=0, highNum=0, lowNum=0, lastNum = 0;
double average;
printf("Enter a number greater than 0: (Enter -1 to stop)
");
scanf_s("%i", &userNumber);

[Code]....

My program outputs everything I need except the lowest number entered. I have been spending a considerable amount of time on this problem to no avail.

View 4 Replies View Related

C++ :: Entering Command Line Arguments?

Jan 11, 2015

I am not sure how to enter command line arguments when I run the executable of the file below. I want check an make sure that only two arguments get into the main() before running the rest of the code. I'm using bash on linux.

An example that I have tried to test for 2 arguments in command line -arg1 arg2 > ./a.out This of course does not work

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

[Code].....

View 4 Replies View Related

C++ :: Entering Valid User Input?

Mar 20, 2013

Entering valid user input?

How can I write my simple program so if the user enters an invalid number, The program won’t exit? I know I am supposed to use a if (cin) or if (!cin), But I don’t know where in the program or how I should use it. Right now my Program looks kind of like this:

If (number > 1 && number < 1001)
Go through some function loops
Else
Cout << “invalid number”;

I need to write it so when the user enters an invalid number, the program Would Keep asking for the right number until it's given.

View 3 Replies View Related

C :: Entering Two Positive Integers To Multiply Together - Program Won't Compile

Aug 24, 2013

I'm trying to get my C program to compile but it's not working at all. I've programmed a little in C++ before but I'm not used to C. Here's my program so far:

Code:
int main(void){
// Establishes variables
int num1, num2, product;
float quotient;

[Code] .....

It keeps giving me an error message as follows:

"/usr/bin/ldrelabwk2: file format not recognized; treating as linker script
/usr/bin/ldrelabwk2:1: syntax error
collect2: ld returned 1 exit status"

View 11 Replies View Related

C :: Inventory Program - Entering Amounts With Two Decimal Places

Jun 7, 2013

So my inventory program runs fine as far as I can tell. Except when entering "Amounts" with more that 1-precision . ie

Amount Entered : 25.99 // Problem
Amount Entered : 25.9 // No Problem

When entering say 25.99, the rest of the file is jibberish. but 25.9, the rest of the file is fine

Code:
#include <stdio.h>
typedef struct toolRecord{
int record_num;
char tool_name[16];
int quantity;
double price;

[Code] .....

View 5 Replies View Related

C++ :: Concatenation Of Strings When Entering City / State And Zip Code

Apr 15, 2013

I have written my code, but can't seem to figure out why it doesn't enter the while loop and start asking for Input.

Code:
#include <iostream>
#include <string>
using namespace std;
int main(){
//declare variables
string cityName = "";
string stateName = "";

[Code] ....

View 3 Replies View Related

Visual C++ :: Showing Time For A User While Entering Some Characters

Dec 26, 2014

Im working on my project for college and i want to know how to add sth similar to a chronometer for user to see how much time have passed while entering some characters using cin.getline function.

View 2 Replies View Related

C++ :: Write Program Where User Will Keep Entering Data Until Pressing Ctrl D

Mar 1, 2013

I'm trying to write a program where the user will keep entering data until pressing control + D. Then the it will display the mean, smallest number, and largest number.

Here are three samples of my program running.

Sample 1
Enter the price for stock 1: $ 10
Enter the price for stock 2: $ 1.555
Enter the price for stock 3: $ 3.648

[Code].....

As you can see in Sample 1, the program runs correctly. The largest number was 20 and the lowest number was 1.555. But in Sample 2, the program shows min as 15.500, where it should be showing 15.000 and Sample 3, the program shows min as 110.000 when it should be showing 55.564.

Here's the code.

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

[Code].....

View 5 Replies View Related

C++ :: Input Validation - Prevent User From Entering Characters Or Symbols Instead Of Numbers?

Jul 19, 2013

How do I prevent user from entering characters or symbols instead of numbers?
int num;
cout<<"Enter a number."<<endl;
cin>>num;

Also, how do I prevent user from entering a number instead of a character?
char c;
cout<<"Enter a character."<<endl;
cin>>c;

View 9 Replies View Related

C++ :: Program To Determine Slope Of A Line - Stuck On Commas When Entering Numbers

Jan 1, 2013

The program I have is from a tutorial where the user enters two points on a line, and then the program calculates the mid-point and slope.

I want to modify it from it's initial form so that co-ordinates can be input in (x,y) fashion. Right now the user has to enter the x-coordinate, enter a space, and then enter the y-coordinate (lame...)

I saw people using SStream and using that to either write functions to ignore the comma or similar things for converting one file into an array, but not quite what I am trying here.

// program to determine slope of a line

#include <ios>
#include <iostream>
#include <istream>
#include <limits>

using namespace std;
void myflush ( istream& in ) {

[Code] .....

View 2 Replies View Related

C++ :: Syntax Error In Function Call - Type Mismatch In Parameter In Function Sort

Jul 6, 2014

error says "cannot convert 'int*' to 'int' in function main()
and also
type mismatch in parameter in function sort(int,int)

Heres the code:
#include<iostream.h>
#include<conio.h>
void main() {
void sort(int,int);
clrscr();

[Code] .....

View 11 Replies View Related

Visual C++ :: Error C3867 Function Call Missing Argument List For Calling Thread Function

Mar 19, 2013

I searched the web for error: C3867... and the discussions where murky or obscure.

My code excerpt is:

#pragma once
#include <windows.h>
#include <stdlib.h>
#include <process.h>
void PutUpfrmIO(void *);
namespace WordParsor {

[Code] .....

I get the generic message:

error C3867: 'WordParsor::Form1::PutUpfrmIO': function call missing argument list; use '&WordParsor::Form1::PutUpfrmIO' to create a pointer to memberc:userskingc++wordparsorwordparsorForm1.h... and the suggestion fix generate another error.

One person suggested the gcroot<> object wrapper... but I do not know how to modify/declair the function or its argument type.

View 2 Replies View Related

C :: Error Going In A Function

Jul 2, 2013

I have no error compiling, but running my project it stops before entering a function and debugging I have an error about Segmentation fault. The function:

Code:
1
2
3
4
5
6
7
Mat logGabor(matriz filter,Mat filter,double r_o,double theta_o,double sigma_theta, matriz radius,matriz theta,int cols,int rows,double sigma_r,int *padSize){

[Code]....

View 5 Replies View Related

C/C++ :: Getting Error Name Function Should Have Prototype

Aug 25, 2014

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main() {
int i=1,j=2;
float k,l=1.5;

[Code] ...

View 3 Replies View Related

C++ :: 0xC0000005 Error When Calling A Function

Sep 12, 2013

I'm new to C/C++. I'm trying to make a program that's going to use the CBLAS libraries that I downloaded on BLAS. After fighting tooth and nail with VC 2005 (I downgraded on purpose because at one point I was desperate.) with regards to solving compilation errors and such and eventually it all compiled just fine.

The problem now is, I get the above mentioned error. It says: "Unhandled exception at 0x0040271c in Try.exe: 0xC0000005: Access violation reading location 0x4e18feb8."

Now there are a few .cpp files (I'm compiling as C code.) which contain the functions and there is one other one which contains my main method. Using the debugger, it goes through 3 files all in all.

The main file: Code: /* cblas_example2.c */

#include <stdio.h>
#include <stdlib.h>
#include "cblas.h"
#include "cblas_f77.h"

[Code] .....

I get the above-mentioned exception in the last line, or:

Code: cblas_dgemm( UNDEFINED, transa, transb, *m, *n, *k, *alpha, a, *lda, b, *ldb, *beta, c, *ldc );

The debugger tells me what the address in the exception is the address if *ldc.

View 6 Replies View Related

C++ :: Error When Translating Function From Matlab To C

Jul 1, 2013

I have en error translating a function from Matlab to C/C++ :

Code:
radius(floor(rows/2+1),floor(cols/2+1)) = 1;
% Get rid of the 0 radius value at the 0
% frequency point (now at top-left corner)
% so that taking the log of the radius will
% not cause trouble.

What I did is:

Code: radius[rows/2][cols/2]=1;

I m sure it s there the problem, because before this line I can print what I want and I can see it at run-time, but after this line I can not print nothing and the work is like blocked. Do you know the error?

View 7 Replies View Related

C :: Passing Values To A Function Error

Apr 29, 2014

I'm working through the Let us C book. One exercise asks me to collect int and float , then pass them to a function that gets product of these and returns it to main. My code looks like this:

Code:

#include <stdio.h>#include <stdlib.h>
main()
{
int a;
float b, c;

[Code]...

So while compiling i get an error about conflicting types for product. I tried to google that error but couldn't understand what's the problem. My only clue is that i can't pass int and float to a function at the same time... Could that be it?

View 6 Replies View Related

C :: Signal Function Defined Twice With No Error?

Dec 13, 2013

I'm using a library in my code in a file called "my_signal.c". In this file I've defined this function:

Code:
Sigfunc * signal(int signo, Sigfunc *func){
struct sigaction act, oact;
...
}

Since the signal function is also in file signal.h and I included it in "my_sygnal.h" file, I'm wondering why the compiler did not say anything about this "double declaration" of the function with the same name.

View 9 Replies View Related

C++ :: Inaccessible Error In Inherited Function

Nov 6, 2013

THis is my small program i am getting error CPP 46: 'result::putdata()'is not accessible

#include<iostream.h>
#include<conio.h>
class stud
{

[Code]......

View 1 Replies View Related

C++ :: Identifying Error In Factorial Function

Apr 8, 2014

double expression(int n, double x) {
double num=(pow((x),2*a));
double den=fact(n,a);
double sum=0;
for(int a=0; a>=0; a++)
sum=pow(x,n)*(num/den);
return sum;
}

I don't know why this isn't working. fact is a factorial function which I have tested and it works fine. But when I input, for example:

int main() {
cout<<expression(1,3)<<endl;
getch();
return 0;
}

it comes up with an error.

View 5 Replies View Related

C++ :: Undefined Reference To Function Error

Nov 19, 2013

I am currently working on a code, but I keep getting a error as follows:

[Linker error] undefined reference to 'getHoursOfTheWeek(double)'
[Linker error] undefined reference to 'getGrossPay(double)'
[Linker error] undefined reference to 'getStateTax(double)'
[Linker error] undefined reference to 'getFederalTax(double)'
[Linker error] undefined reference to 'getFICA(double)'
[Linker error] undefined reference to 'getWithHoldingAmount(double)'

I have been trying to debug this error for hours and I am completely stumped....

//BEGIN
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
string getUserName();
double getPayRate();

[Code] .....

View 2 Replies View Related

C/C++ :: Error While Passing 2D Array To A Function

Nov 23, 2014

I'm trying to pass an 2d array to a function, but i'm getting this error message:

Error: 'p' undeclared here (not in a function)

#include <stdio.h>
void regStock(int stock[][p], int a);
int main( ) {
int a, p;
scanf("%d", &a);
scanf("%d", &p);

[Code] .......

View 6 Replies View Related

C++ :: Error / No Matching Function For Call

Dec 14, 2013

This code from [URL] as it is gives compile error I can't understand.

#include <iostream>
using namespace std;
class Rectangle {
int width, height;

[Code] ....

Gives error

(g++ first.cpp)
first.cpp: In function ‘int main()’:
first.cpp:14:38: error: no matching function for call to ‘Rectangle::Rectangle(<brace-enclosed initialiser list>)’

View 3 Replies View Related







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