Sponsored Content
Top Forums Programming warning: comparison between pointer and integer Post 302565053 by agama on Sunday 16th of October 2011 03:03:47 PM
Old 10-16-2011
You've got double quotes when you need single quotes:


Code:
(input_message[output] == " ")

The " " is a pointer to a string (of a single blank) while input_message[output] is a single character (converted to int for comparison).


Also, the statement input_message != " " won't ever evaluate to true, as you're comparing two pointers and not what the pointers reference. Have a look at strcmp() and strncmp() functions which I think will do what you want in this situation.


There may be other issues; I didn't look all that closely.
This User Gave Thanks to agama For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

Will we get SEGV if we try to “delete []” un-initialized integer pointer variable.

I have a class with an integer pointer, which I have not initialized to NULL in the constructor. For example: class myclass { private: char * name; int *site; } myclass:: myclass(....) : name(NULL) { ..... } other member function “delete “ the variable before... (2 Replies)
Discussion started by: sureshreddi_ps
2 Replies

2. Programming

comparison between pointer and integer

I received a warning when I tried to compile my program that said: warning: comparison between pointer and integer Could you please explain to me what this means, and in what ways I could possibly fix this? Thanks for your help! (2 Replies)
Discussion started by: sjung10
2 Replies

3. Programming

`strcat' makes pointer from integer without a cast

A question to ask. seq1 = "eeeeeeeeeeeeeeeeee"; seq2 = "dddddddddddddddddddd"; char a = '*'; strcat(*seq2, &a); strcat(*seq1, seq2); compilation warning: passing arg 1 of `strcat' makes pointer from integer without a cast thanks (4 Replies)
Discussion started by: cdbug
4 Replies

4. Programming

pass a pointer-to-pointer, or return a pointer?

If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it: (1) one is to pass a pointer-to-pointer parameter, like: int my_malloc(int size, char **pmem) { *pmem=(char *)malloc(size); if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies

5. Programming

warning: passing arg 1 of `inet_addr' makes pointer from integer without a cast

I use solaris10,following is tcp client code: #include "cliserv.h" int main(int argc,char argv){ struct sockaddr_in serv; char request,reply; int sockfd,n; if(argc!=2) err_quit("usage: tcpclient <IP address of server>"); if((sockfd=socket(PF_INET,SOCK_STREAM,0))<0) ... (1 Reply)
Discussion started by: konvalo
1 Replies

6. Shell Programming and Scripting

integer comparison in ksh

Hi, I am just trying to compare integer in ksh. can you please tell me what's wrong with this code... or give me suggestions on alternative. sample code: i=0; if ; then echo inside if fi Thanks in advance! (6 Replies)
Discussion started by: nram_krishna@ya
6 Replies

7. UNIX for Dummies Questions & Answers

Counting vowels in string. "Comparison pointer-integer".

I'm trying to write a programme which scans strings to find how many vowels they contain. I get an error saying that I'm trying to compare a pointer and an integer inif(*v == scanme){. How can I overcome this ? Also, the programme seems to scan only the first word of a string e.g.: if I type "abc... (1 Reply)
Discussion started by: fakuse
1 Replies

8. Shell Programming and Scripting

Doubt in integer comparison

Hi What is the difference between following commands Command1 length=1 if ] ; then echo "Hellow world" fi Command 2 length=1 if ] ; then echo "Hellow world" fi which is correct usage from this (2 Replies)
Discussion started by: morbid_angel
2 Replies

9. Shell Programming and Scripting

[Solved] String integer comparison

I am trying to execute something like this file=/tmp/test.txt firstline=$(head -n 1 $file) value=`echo $firstline | cut -d'=' -f2` if then echo true fi i read the first line of a file, cut to the numeric value in the first line and check if it greater than 2 but for some... (11 Replies)
Discussion started by: madhan_dc
11 Replies

10. Programming

Warning: pointer type mismatch

Hi all, I'm new programming in C, so I had the next message in my code: Dual.c:88:20: warning: pointer type mismatch in conditional expression : &clientSa.sin6.sin6.sin6_addr, Any help would be great #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include... (1 Reply)
Discussion started by: godna
1 Replies
UPRECORDS(1)						      General Commands Manual						      UPRECORDS(1)

NAME
uprecords - provides uptime records SYNOPSIS
uprecords [ -?abBcfkKMsv ] [ -i <interval> ] [ -m <count> ] DESCRIPTION
This manual page documents the uprecords program. uprecords is a program that provides record statistics from the uptimed(8) program. OPTIONS
-? Show usage -a Do not print ANSI codes -b -B Sort by time of bootup, oldest entry first. -B reverses. Option implies -s. Do not print ANSI codes -c Do not show current entry if not in top entries -f Run continuously in a loop -k -K Sort by kernel/system name. -K reverses. Option implies -s. -M Show next milestone -s Do not print extra statistics -i <interval> Use <interval> seconds for loop instead of 5, implies -f -m <count> Show a maximum of top COUNT entries instead of 10 -v Show version information SEE ALSO
uptimed(8) AUTHOR
Rob Kaper <cap@capsi.com>. This manual page was written by Alan Ford <alan@whirlnet.co.uk>, for the Debian GNU/Linux system (but may be used by others). It was last modified for uptimed version 0.3.7. June 20, 2004 UPRECORDS(1)
All times are GMT -4. The time now is 08:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy