Sponsored Content
Top Forums Programming warning: comparison between pointer and integer Post 302565048 by solaris_user on Sunday 16th of October 2011 01:59:45 PM
Old 10-16-2011
warning: comparison between pointer and integer

Hi guys Smilie

I am still playing with my C handbook and yes, as you can see I have small problem as always Smilie

Quote:
Teksbook says
Write a program that reverses the words in sentence.
Use a loop to read charactes one by one and store them in
one-dimensioal char array. Have the loop stop at a period,
question mark or exclamantion point and store it in separate
char varible. Then use a second loop to search backward through the array for the begging og the last word. Print the last word then search backward for the next-to-lat word. Repeat until beginning of the array is reached. Finnaly print the termination character.
I wrote a C code
[C] #include <stdio.h> #define MESSAGE 100 int main(void) { char input_mes - Pastebin.com

And when I try to compile it I get following errors from gcc

Code:
14.c: In function ‘main':
14.c:33: warning: comparison between pointer and integer
14.c:35: warning: comparison between pointer and integer

I removed comments so code be more nice.

And this isn't my homework, it is a self-learnig so if this is a wrong place to put question please move it where belongs.

Thanks for reading Smilie
 

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 05:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy