473,378 Members | 1,218 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

The meaning of these warnings. C language

5 Nibble
Hi,

I just started studying C programming and I began to make a console program project. I am using code block for my compiler. Looks like every time I use if statement, this warning always come

|warning: assignment to 'int' from 'char *' makes integer from pointer without a cast [-Wint-conversion]

warning: suggest parentheses around assignment used as truth value [-Wparentheses]|

All I want to know is what are these warnings meaning.
Sep 6 '20 #1

✓ answered by dev7060

If the vars are declared as int,
Expand|Select|Wrap|Line Numbers
  1. if (menu == 1)
  2.  
Expand|Select|Wrap|Line Numbers
  1. if (menu_pitagoras == 1)
  2.  
For string comparison,
Expand|Select|Wrap|Line Numbers
  1. if(strcmp(menu, "1")==0)
  2.  

8 3229
dev7060
636 Expert 512MB
The warnings exactly mean what the text says. Show your code.
Sep 6 '20 #2
mrgenousprogram
5 Nibble
So, is there anything I can do to fix this or I don't need to do anything?
Sep 6 '20 #3
dev7060
636 Expert 512MB
Potential issues are indicated by warnings. Warnings would not prevent the code from being compiled. To produce a robust thing, warnings should never be ignored.
So, is there anything I can do to fix this or I don't need to do anything?
I can't suggest the fix if I don't know in the first place what is there to apply the fix to.
Sep 6 '20 #4
mrgenousprogram
5 Nibble
These are the codes that got warned

Expand|Select|Wrap|Line Numbers
  1. if (menu_pitagoras = "1")
Expand|Select|Wrap|Line Numbers
  1. if (menu = "1")
all the codes that are contained within the if statement got neither warnings nor errors

these are the codes inside the if statement

Expand|Select|Wrap|Line Numbers
  1. if (menu = "1")
  2.     {
  3.         printf ("\n1. Alas\n2. Tinggi\n3. Diagonal\nPilih sisi:");
  4.         scanf ("%d", &menu_pitagoras);
  5.  
  6.         if (menu_pitagoras = "1")
  7.         {
  8.             printf ("\nTinggi:");
  9.             scanf ("%f", &tinggi);
  10.             printf ("\nDiagonal:");
  11.             scanf ("%f", &diagonal);
  12.  
  13.             pitagoras_alas = sqrt (tinggi*tinggi+diagonal*diagonal);
  14.  
  15.             printf ("\nHasil:%f", pitagoras_alas);
  16.             }
just in case if these codes needed to be checked
Sep 7 '20 #5
dev7060
636 Expert 512MB
Use strcmp() for strings (represented as char arrays in C) and use comparison operator instead of assignment one for integer values.
Sep 7 '20 #6
mrgenousprogram
5 Nibble
Ummm, can you please give an example?
Sep 7 '20 #7
dev7060
636 Expert 512MB
If the vars are declared as int,
Expand|Select|Wrap|Line Numbers
  1. if (menu == 1)
  2.  
Expand|Select|Wrap|Line Numbers
  1. if (menu_pitagoras == 1)
  2.  
For string comparison,
Expand|Select|Wrap|Line Numbers
  1. if(strcmp(menu, "1")==0)
  2.  
Sep 7 '20 #8
mrgenousprogram
5 Nibble
Excellent, you're my project savior. I can finally continue my project
Sep 7 '20 #9

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

Similar topics

2
by: Roger Erens | last post by:
Dear list, I'm trying to install python2.3.1 on an SCO-box. After running ./configure --prefix=/usrdir/rogere the output of make shows (among others:) running build running build_ext...
2
by: Naren | last post by:
Hello All, I dont get errors but I get warnings though the code runs fine. Could anyone help me removing these warnings c:\program files\microsoft visual studio\vc98\include\vector(48) : warning...
15
by: Birahim FALL | last post by:
Hi, I'm very fresh to PostgreSQL, coming from Oracle. I want to developp web applications based on apache and postgresql. Is there an equivalent of OWA server (Oracle Web Application server) for...
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...
6
by: Sathyaish | last post by:
I am practicing function pointers. Here's what I am doing: passing a function pointer to another function. It all goes well except for the two warnings I get: (1) 'ConsumeFnPointer' : too many...
134
by: evolnet.regular | last post by:
I've been utilising C for lots of small and a few medium-sized personal projects over the course of the past decade, and I've realised lately just how little progress it's made since then. I've...
6
by: pete142 | last post by:
When I compile this code: typedef unsigned char BYTE; BYTE * IpString(unsigned int ip) { static BYTE ipString; ipString = (BYTE) 0xff & (ip >24); ipString = (BYTE) 0xff & (ip >16);
20
by: somenath | last post by:
Hi All, I have one question regarding the code. #include<stdio.h> char *f1(void); char *f1(void) { char *abc ="Hello";
1
by: nirmaltech28 | last post by:
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.