473,473 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to clear these warnings?

2 New Member
Iv written a C program for playing tic-tac-toe between a computer and a user. Iv used lots of pointer variables and passing those variables to functions to functions. Im getting some warnings and also the program is not executing properly. I dont know whether it is because of warnings or I did logical errors in the program.
WARNING:
1. assignment makes a pointer from Integer without a cast.
2. passing arg1 of 'display' from incompatible pointer type.
Could anybody help me to give solution to this warning. It will be better if you guide why im not getting the expected output.
Below I place the error code. If u have to see my whole program for better checking it go to http://paste.pocoo.org/show/250129/
Compiled in gcc..

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. void display();
  4. int main()
  5. {
  6. int *a[3][3],i,j;
  7. for(i=0;i<3;i++)
  8. {
  9. for(j=0;j<3;j++)
  10. a[i][j]=0;
  11. }
  12. a[1][1]=1;      //this is where I get the first warning
  13. display(&a);    //and the second warning is this
  14. return 0;
  15. }
  16. void display(int *p)
  17. {
  18. int *a[3][3],i,j;
  19. for(i=0;i<3;i++)
  20. {
  21. for(j=0;j<3;j++)
  22. {
  23. a[i][j]=*p;
  24. p++;
  25. printf("%d\t",a[i][j]);
  26. }
  27. printf("\n");
  28. }
  29. }
  30.  
Aug 14 '10 #1
1 1520
weaknessforcats
9,208 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. a[1][1]=1;      //this is where I get the first warning 
The array is a 3x3 array of pointers to int. Therefore, you need to assign addresses of int rather than int values. That is, 1 is not a valid address for an int.

Did you mean you have a exe array of int?

Expand|Select|Wrap|Line Numbers
  1. display(&a);    //and the second warning is this 
Your display function takes an int* argument but your prototype says no arguments.
Aug 14 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Kylotan | last post by:
I have the following code: def IntToRandFloat(x): """Given a 32-bit integer, return a float in """ x = int(x) x = int(x << 13) ^ x return...
12
by: Gary | last post by:
Hi! guys, I have a SQL agent job fails because it gets 10 warnings when it runs a stored procedure. These warnings are trivial and can be ignored. Can I make it ignore these warnings and...
4
by: PMB | last post by:
Thank you in advance for any and all assistance. I'm running Queries for updating my forms and I want to turn off the Internal Warnings that access gives. How do I do that? Michael
5
by: Andrew Slade | last post by:
Hello, I am making calls from one compilation unit to functions in another by pointers and I get the warnings below from gcc on 2.4.x Debian Linux. The executable seems to work fine but the...
15
by: Walter Dnes (delete the 'z' to get my real address | last post by:
I'm trying to initialize an array of error messages, so that I can print out an error message by using the 'nth string in an array, e.g. printf("%s\n", messages); I'm still hazy on arrays of...
22
by: John Fisher | last post by:
void f(int p) { } Many (most?) compilers will report that p is unreferenced here. This may not be a problem as f may have to match some common prototype. Typically pointers to functions are...
5
by: rawCoder | last post by:
Hi All, In Visual Basic .NET , your function definition might requirre you to return a value but (accidently/intentionally) you dont put any 'return value' in the function. In this case VB...
4
by: Dave | last post by:
TIA for the help.....this should be easy for a pro....I need the two divs with text to display on the same line at the top of the container..??? <html> <head> <style> body...
1
by: =?Utf-8?B?RWRC?= | last post by:
I guess my thing is that if you let the warnings sit then what's the point of having them, so I like to clear them and I have a couple that I can't seem to. 1) Access of shared member, constant...
82
by: robert bristow-johnson | last post by:
here is a post i put out (using Google Groups) that got dropped by google: i am using gcc as so: $ gcc -v Using built-in specs. Target: i386-redhat-linux Configured with: ../configure...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.