C/C++ :: Warning / Assignment From Incompatible Pointer Type

Apr 17, 2014

I'm working on a program and everything works except for the follow function:

void swapHex(int x, int byte1, int byte2) {
unsigned char *b1, *b2, tmpc;
printf("%d in hex is %x
", x, x);
printf("swapping byte %d with byte %d
", byte1, byte2);

[Code] ....

I get the following errors when compiling:

In function "swapHex":
warning: assignment from incompatible pointer type
warning: assignment from incompatible pointer type

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/C++ :: Return From Incompatible Pointer Type

Jul 13, 2014

/*
* symboltable.c
*/

#include "symboltable.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "include/utlist.h"

[Code] ....

View 2 Replies View Related

C/C++ :: Error - Initialization From Incompatible Pointer Type

Apr 8, 2012

Below is my code snippet.I'm getting "Error:initialization from incompatible pointer type" error on line 'int *q = status;'.

Obviously, I'm missing something but has no clue...:(

void findwalls(int *p,int y,int x){
int status[y_count][x_count][4];
int *q = status;
for(int i = 0;i < (y_count * x_count * 4);i++)
*(q + i) = *(p + i);

View 1 Replies View Related

C :: Function To Read A Text File - Incompatible Pointer Type

Nov 3, 2014

So for a project, my professor sent out two pages of code containing functions to read a text file (since we do not know how to write this on our own yet). I've got the code working on Orwell IDE and it gives me 2 warnings saying

"Passing argument 1 of 'readFromFile' from incompatible pointer type"

"Passing argument 2 of 'option2Print' makes integer from pointer without a cast"

The Orwell IDE seems to just bypass these warnings and compiles the code correctly. However, when I transferred my files over to my desktop using BloodShed (what the professor uses), instead of getting a warning I get an error and the code won't compile.

I assume it will not compile on his computer either since he uses the BloodShed IDE.

I don't know how to put the code directly into the text neatly, so a attached a .zip file with my code. The "storms.txt" file is also included. (the file that will be read).

View 4 Replies View Related

C++ :: Generic Linked List Compilation Errors / Incompatible Pointer Type

May 19, 2014

I am trying to write a generic linked list in c, but for some reason i keep getting errors saying "incompatible pointer type. This is the code and erros:

#ifndef SLIST_H
#define SLIST_H
#include <stdlib.h>
typedef struct {
void *data;
slist_elem *next;

[code]....

View 2 Replies View Related

C :: Error - Incompatible Types In Assignment

Oct 11, 2013

I am working on a double linked list and inside of my function to insert a node, I am getting an error of "Incompatible types in assignment". Here is my function code. Line 55 is where I am receiving the error.

Code:

45 struct lnode *ins_llist(char data[], struct llist *ll){
46 struct lnode *p, *q;
47
48 q = malloc(sizeof(struct lnode));
49 if ( q == NULL )

[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 :: Warning When Handling Pointer To Char

Apr 4, 2014

Here is my code. I am combining two words and sorting the merge word in alphbetical order. The compiler giving me warning error

Program:12:4: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat] Program:14:4: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat]

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

[Code].....

View 3 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 :: 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++ :: Return Type For Assignment Operator

Apr 7, 2014

I am wondering why return type for an assignment operator cant be a void or int? Cant I write assignment operator for student class like this as we do nothing with returned value?

Student {
char name[20];
int marks;
public:
student(char*name,int marks)

[code].....

View 2 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++ :: Member Function Pointer Assignment?

May 15, 2013

I have a class with member functions and a pointer like this:

Code:
class MyClass{
private:
typedef void(MyClass::*memFnPtr_t) ();
public:
memFnPtr_t fnptr;
void fn1();
void fn2();
};

Now in a regular function I create an instance of the class and try to assign the pointer:

Code:
MyClass mc;
mc.fnptr = &mc.fn1;

The compiler does not like it and suggests this instead:

Code:
mc.fnptr = &MyClass::fn1;

This seems to work but what if I have two instances of the class:

Code:
MyClass mc1, mc2;

How does the compiler know to distinguish between

Code:
mc1.fn1

and

Code:
mc2.fn1

when the assignment now looks identical:

Code:
mc1.fnptr = &MyClass::fn1;
mc2.fnptr = &MyClass::fn1;

View 14 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++ :: Create Assignment Operator For A Class That Uses Pointer For Its Private Variable?

Mar 30, 2013

i am trying to create the assignment operator for a class that uses a pointer for it's private variable. The error is saying expected constructor, deconstructor, or type conversion before "operator. (which is the assignment operator. I have tried everything i could think of or find online and nothing has worked. below is the code for the assignment operator in the .h file and the .cpp file.

//Assignment constructor
indexList &operator=(const indexList <T> &rhs);
template <class T>
indexList<T>::indexList operator=(const indexList <T> &rhs) {
if(this != &rhs) {
numberOfElements = rhs.numberOfElements;

[Code]...

View 1 Replies View Related

C/C++ :: Error - Cannot Convert To A Pointer Type

Apr 3, 2015

I have attached the source code I am writing. I have been getting the two following errors. I know it's something to do with the pointer casting.

udp-server.c:174:3: error: subscripted value is neither array nor pointer nor vector
udp-server.c:165:3: error: cannot convert to a pointer type

The file is attached here.
udp-server-edit.txt (7.64K)
Number of downloads: 19

View 3 Replies View Related

C/C++ :: Dereferencing Pointer To Incomplete Type

Feb 27, 2014

keep getting "deferencing pointer to incomplete type" on the bold lines:

main:
int main(int argc, char *argv[]) {
printf("Please think of an animal. I will try to find out what it is by asking you some yes/no questions.");
struct treenode *root = mkTreeNode("Is it a reptile?
", NULL, NULL);
struct treenode *selectedNode = root;
root->left = mkTreeNode("Does it have legs?

[code]....

View 14 Replies View Related

C++ :: Function Pointer Typedef With Same Type Arguments

Mar 6, 2015

I need to create the following brain damaging abomination:

I need a function pointer type to a function that has an argument of the same function pointer type and returns the same function pointer type.

The purpose is to enable a type of subroutine threading scheme for a small application specific scripting language. The question could just as well have been posted to the C forum.

This syntax works, but Payload is a generic type which I can coerce into the right pointer type via a cast. This is ugly IMHO. I could also hide it as a pointer in the FlipState class since I've forward declared this.

But this is an extra indirection in a performance critical part of the code, and also ugly.

Code:
class FlipState ;
typedef PayLoad (*FuncPtr) (FlipState *fs, PayLoad P) ; This syntax blows chunks using gcc on the other hand. Code: class FlipState ;
typedef FuncPtr (*FuncPtr) (FlipState *fs, FuncPtr P) ;

[Code] .....

This is hardly surprising. The compiler could not possibly understand what I was defining in the typedef. I think what I need is some kind of way to forward declare a function pointer type and then redefine it properly.

Is such a think even possible or am I just SOL? This one is mind boggling. We know how to do this with classes or other complex data types, but the syntax eludes me for both C++ and C.

View 4 Replies View Related

C :: Unsigned Char - Pointer Type Casting

Dec 2, 2013

I came across some code and it's not clear why it is casting an unsigned char * to another pointer type only to free it right after. Here are the relevant structures:

Code:
struct _Edje_Message {
Edje *edje;
Edje_Queue queue;
Edje_Message_Type type;
int id;
unsigned char *msg;

[Code] .....

As you can see, _Edge_Message has a *msg field, but in the function below, they cast it to the other two structure types inside the case blocks of the switch statement only to free it. What is the point or advantage of doing this?

Code:
void
_edje_message_free(Edje_Message *em) {
if (em->msg) {
int i;
switch (em->type) {

[Code] ......

View 14 Replies View Related

C :: Array Of Char Pointer Type Mismatch

Apr 20, 2013

I have an array of char pointers:

Code: char *input_args[MAX_ARGS];

And I have this function:

Code: BOOL parseArgs(char **input_args[], input arg_num);

I am trying to pass a pointer to this char pointer array like this:

Code: parseArgs(&input_args, args_num);

But the compiler is complaining:

Code: warning: passing argument 1 of 'parseArgs' from incompatible pointer type ...

note: expected 'char ***' but argument is of type 'char * (*)[20]'

Tried a bunch of stuff but nothing works.

View 4 Replies View Related

C :: Error - Dereferencing Pointer To Incomplete Type

Feb 21, 2015

I've been writing the math functions for a 3d game and tried compiling it at about 30 functions in. I get this error related to my pointers to my structures. it affects almost everything in all my functions (as youll see by looking at how i do the math in the function below). The compiler gives me the error

"error: dereferencing pointer to incomplete type"

on all my struct Type4D pointers but referencing the values in my struct TypeMatrix4X4 using pointers seems to work fine i think (it doesn't seem to complian explicitly about it. so here is the important code...

one example function

Code:
struct Type4D *MatVecMult4X4RtoL(struct TypeMatrix4X4 *mat, struct Type4D *vec) {
struct Type4D *dest = (struct Type4D *) malloc(sizeof(struct Type4D));

[Code]....

View 2 Replies View Related

C++ :: How To READ Pointer Of A Struct Type In File

Nov 23, 2013

This is a c++ Code. I want to read a address to a pointer. When I try to do so it generates an error. I did is >> obj1[0].contentAdress; in main.

struct node3{
node3(){
nextContent = NULL;
for (int i = 0; i<1020; i++)
content[i] = '';

[code]...

no operator found which takes a right-hand operand of type 'node3 *' (or there is no acceptable conversion)

View 12 Replies View Related

C++ ::  subscript Requires Array Or Pointer Type

Sep 15, 2013

I keep getting this error?

Error1error C2109: subscript requires array or pointer type

Code:
#include <iostream>
using namespace std;
void mean(int [],int);
int main() {
const int arraySize = 25;
const int patternSize = 10;

[Code] .....

View 2 Replies View Related

C++ :: Error Dereferencing Pointer To Incomplete Type

Jul 10, 2013

I am having trouble with this program I get the error dereferencing pointer to incomplete type in the populate function I am using BloodShed's Dev C++ compiler v4.9.9.2 I copied this program out of a book because I was having a problem with a linked list in a similar program. I think there is a problem with the compiler not supporting these types of pointer's in a function.

#include <stdio.h>
struct tel_typ {
char name[25];
char phone_no[15];
struct tel_typ *nextaddr;

[code].....

View 3 Replies View Related







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