C++ :: ISO Forbids Comparison Between Pointer And Integer

Apr 21, 2013

I am trying to make a program that prints out an 8 by 8 board with 1 queen on each row.

For example, if the user enters: 0,3,4,0,0,7,6,7

the program should create following board and print:

Q.......
...Q....
....Q...
Q.......
Q.......
.......Q
......Q.
.......Q

I think I am doing it right but im getting a couple of errors that i cant fix ...

#include <iostream>
using namespace std;
int main(){
int x [8] [8], r, c;
for(c = 0; c <= 8; c++){
cout << " Enter a number from 1 to 7 " << endl;

[Code] .....

these are the errors :

assignment15_meem.cpp: In function âint main()â:
assignment15_meem.cpp:7: error: no match for âoperator>>â in âstd::cin >> x[c]â
assignment15_meem.cpp:10: error: ISO C++ forbids comparison between pointer and integer

View 7 Replies


ADVERTISEMENT

C/C++ :: ISO Forbids Comparison Between Pointer And Integer

May 4, 2014

template <class ST>
bool OrderedSet<ST>::IsIn (const ST & value) const {
for (LNode * np = first; np != NULL; np = np -> next)
if (np -> next == value)
return true;
return false;
}

View 1 Replies View Related

C++ :: Linked List Set Function - Forbids Comparison Between Pointer And Integer

May 5, 2014

I'm trying to write a function called 'set' that sets the value of the i'th cell to val on my linkedList, and then returns the previous contents. I am stuck on it due to compiling errors:

This is my Node struct:

#ifndef NODE_H
#define NODE_H
#include <iostream>
template <typename T>
struct Node {
friend std::ostream &operator <<(std::ostream &os, const Node<T> &node) {

[Code] ....

The following is my set function:

template <typename T>
T set(Node<T> *head, int i, const T &val) {
for(int n = 0; n < i; n++)
if(head == val) {
val = i;
} return val;
} #endif

When I try to call it in the main() I get these errors:

node_utils.h: In function ‘T set(Node<T>*, int, const T&) [with T = int]’:
node_demo.cpp:26:38: instantiated from here
node_utils.h:161:2: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
node_utils.h:162:3: error: assignment of read-only reference ‘val’

So, I understand that I can't compare head & val on my if-statement -- But what do I do?

View 7 Replies View Related

C/C++ :: ISO Forbids Comparison Between Ptr And Int For Types

Jul 14, 2014

This is some code that simulates files and directories the same way an operating system does so. I commented out every std::string occurrence because I got the :

terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_S_create

View 3 Replies View Related

C :: Assign Pointer Of A String To Integer

Mar 22, 2014

I have this code:

Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
[code]....

What I want is basically to assign to the *p the pointer of the string so that i could do the following printf(" print string %s",*p); so i dont know how to do that.

View 6 Replies View Related

C :: Makes Integer From Pointer Without Cast

Mar 18, 2013

The warning: :63:7: warning: passing argument 1 of fputc makes integer from pointer without a cast [enabled by default]

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>

[Code]....

View 2 Replies View Related

C :: Incompatible Integer To Pointer Conversation

Nov 28, 2013

I am getting error"incompatible integer to pointer conversation..." and don't know how to fix this. In my code, user inters line like this (3+3*(55-52)) I need to separate number from the line so I can do other operation.here is my code

Code:

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

[Code]....

View 1 Replies View Related

C :: Making Integer From Pointer Without A Cast

Dec 15, 2013

Code:
#include <stdio.h>
#include <stdlib.h>
#define CLASS 4
#define STUDENT 11
#define GRADE 5

[Code] ....

Giving me that error on 75:10
avesub+=grade[k];
and 90:17
donkeypunch+=grade[j][k];

not sure exactly why

View 8 Replies View Related

C :: Typecast - Integer To Structure Pointer

Aug 5, 2014

I have written this program

Code:
#include <stdio.h>
#include <string.h>
int main(void) {
struct point {

[Code] ....

error: request for member is not a structure or union
printf("%d
,%d
",p1->i,p1->j);

I was just trying to typecast a integer pointer to structure pointer, but throws error as shown.

View 5 Replies View Related

C++ :: Why Assignment Makes Pointer From Integer

Jul 27, 2013

when i compile the following program i get a compiler warning, but i don't understand why. for me the code seems to be all right and does legitimate this warning. so here is the code

// multiplication.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "crypto.h"
#define PROGNAME "multiplication"
void usage();
int isnumaber(char* str);

[code]....

View 2 Replies View Related

C++ :: Pointer - Allocate Integer Variable To T

Mar 29, 2012

In the code below:

void test(int * i) {
i = new int;
*i = 10;
cout << "i: " << *i << endl;

[Code] ....

The outuput is:

i: 10
t: (some memory position).

If I really want to allocate an integer variable to t, i need to modify the void test(int * i) procedure to void test(int *& i).

View 2 Replies View Related

C++ :: Integer Pointer - Get Address Without Allocating Memory

Jun 3, 2013

I have an integer pointer and i want its address without allocating memory,

main() {
int *a;
cout<<a;
}

This is giving 00000000 and its but obvious. Now if i use address of a (&a) along with *a,

main() {
int *a;
cout<<a;
cout<<&a;
}

'cout<<a' gives me a constant address but 'cout<<&a' gives me different address.

what is the reason behind & and why behaviour of 'cout<<a' changes when using with &.

View 8 Replies View Related

C/C++ :: Warning - Cast From Pointer To Integer Of Different Size

Jan 23, 2014

int hash = 0;
char *strings[100];
if((int)strings[i] != 0)
if((int) strings[hash] != 0)
while((int) strings[hash] != 0)
if((int)strings[hash] != 0)
if((int)strings[hash] != 0)

View 12 Replies View Related

C++ :: Creating A Pointer To Dynamic Integer Array?

Sep 15, 2013

Create in the private section of the ServerGroup class a pointer to a dynamic integer array called servers.

#ifndef ServerGroup_h
#define ServerGroup_h
class ServerGroup {
public:
private:
int *ptr = new int; // needs pointer to a dynamic integer array called servers
};
#endif

View 2 Replies View Related

C :: Passing Argument 1 Makes Pointer From Integer Without A Cast

Mar 6, 2015

Code:
#include<stdio.h>
print_int_ptr(int *a){

printf(" a %i
" ,a);
printf(" &a %i
" ,&a);

[Code] .....

I get that warning : passing arg 1 of `print_int_ptr' makes pointer from integer without a cast|

View 3 Replies View Related

C :: Passing Arg 1 Of Strcmp Makes Pointer From Integer Without Cast

Jan 18, 2015

Code:

#include <stdio.h>
int main(){
int a=15 ;
int b =20 ;
strcmp((a, "20") == 0) {
printf("Correct!");

[Code] .....

passing arg 1 of `strcmp' makes pointer from integer without a cast

View 11 Replies View Related

C :: Passing Argument 1 Makes Integer From Pointer Without A Cast

Mar 26, 2014

I am having some errors with pointers and passing arguments.

Code:

#include <stdlib.h>
#include <stdio.h>
#define MAX_FILE_LENGTH 20
typedef struct node_{
int value;
struct node_* next;

[Code]....

View 3 Replies View Related

C :: Warning - Return Makes Pointer From Integer Without A Cast

Sep 21, 2013

I have a function that I want to exit gracefully when an "error" occurs in an input file. My function declaration is:

Code: BSTnode *buildTree(FILE *fp)

The few lines that are causing the problems are:

Code: if(regcomp(®ex, to_find, REG_EXTENDED | REG_NEWLINE) != 0) {
fprintf(stderr, "Failed to compile regex '%s'
", to_find);
return EXIT_FAILURE;
}

I know that if I just use "return" by itself the warning goes away but fails to exit when the error occurs. I also believe this may not be the correct use of stderr. But I need the program to exit when an error has occurred.

View 9 Replies View Related

C++ ::  In Function Assignment Makes Pointer From Integer Without A Cast

Jul 4, 2013

The log file gives me: In function ‘memFileAlloc’ assignment makes pointer from integer without a cast..When compiling the drivers for the Matrox card in the DL580. The offending code is:

STACK_LINKAGE MEMHANDLE memFileAlloc(
UINT32 dwSize,
const char* pszFileName,
int iLine) {
void* pvChunk;
#if MEMORY_STATS

[code]...

I think the offending line is:
pvChunk = ClientMemAlloc(dwSize + sizeof(UINT32), NULL)
because that's what the log file tells me.

The system is a 16 core HP DL580 G4 with 8g RAM, RAID 0, Mandrivalinux 11.0 and the display is a Matrox Parhelia 256PCIx.

View 11 Replies View Related

C++ :: Comparison Of Two XML Files?

Feb 2, 2015

I need a program that can compare two xml files for equivalency using any XML Parser.

View 2 Replies View Related

C/C++ :: Comparison Of Excel And CSV

Mar 6, 2012

I have to compare data in excel and csv based on the file name and update the status of file from CSV into excel file by creating a new column status on weekly basis.

View 1 Replies View Related

C++ :: Overloading Comparison Operators For Using In A Set

Oct 30, 2014

I have a small piece of code that used the set::insert function on a set of myClass. For that, I need to overload the < and > operators, which I have, but I still get a huge error saying it can't compare.

set<MyClass> mySet;
MyClass myClass

All the class information gets filled in. Then, I try to insert...
mySet.insert(myClass);

bool operator<(MyClass &lhs, MyClass &rhs) {
return lhs.name < rhs.name; //name is a string
}

The error says
...stl_function.h:230:22: error: no match for 'operator<' in '__x < __y'
MyFile.h:80:6: note: candidate is bool operator<(MyClass&, MyClass&)

View 5 Replies View Related

C++ :: Vector Comparison Out Of Range?

Jul 31, 2013

I'm making a simple game and I'm having trouble creating boundaries for the players movements. The map is a 2D vector. When I compare the vector with the players current position sometimes I get an error during run. When the error isn't occurring the behavior of the boundaries is bizarre. The error tells me that the vector is out of range.

Here is the where the map is created. It's within its own class constructor.

vector< vector<char> > map_parts;
map_parts.resize(25);
for ( int i = 0; i < 25; i++ )
{

[Code].....

View 1 Replies View Related

C++ :: Comparison With Uppercase / Lowercase?

Jul 28, 2014

I have this statement - while(strcmp(x[i],"Stop")!=0); - is there anyway to compare x[i] to all the possible forms of "stop" (Stop, STOP, sTop, etc)?

View 4 Replies View Related

C/C++ :: Overloading Comparison Operators

Aug 28, 2014

I made a program that allows the user to enter information of credit cards on an array of size 5, however I need to allow the user to compare the five credit cards with each other and I am having problems with this particular part. I made my bool operator functions for the operator< and the operator> but how to make the user be able to select which cards he wants to compare and how to compare them. My code is the following:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int SIZE = 5;
enum OPCIONES {CARGAR=1, ABONAR, NADA};

[Code] ......

View 2 Replies View Related

C++ :: One Letter Of A String Comparison

Jan 21, 2013

I just would like to turn this into cpp:

string eg("azertyFTW");
if(eg[one of the letters contained in this string] == 'c') {
cout << "eg has the letter c in it";
} else {
cout << "not this time :(";
}

View 4 Replies View Related







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