Thread: operator has no effect ??

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    70

    operator has no effect ??

    Hi
    I do not understand why the compiler is returning the message
    '|' has not effect; expected operator with side effect on the line

    saved_char|0x080;


    Code:
    #include <stdio.h>
    
    
    int main(int argc,char **argv)
    {
    
    	int input_char;
    	int saved_char;
    	int i,rotate,temp;
    	int input_array[8];
    	int rotate_array[8];
    
    
    	printf("What is the input character?");
    	scanf("%c",&input_char);
    
    	saved_char=input_char;
    
    	for(i=0;i<8;i++)
    	{
    		if((input_char&1)==1)
    			input_array[i]=1;
    		else
    			input_array[i]=0;
    
    		input_char>>=1;
    	}
    
    	printf("\n\nArray is\n");
    	for(i=7;i>-1;i--)
    		printf("%d",input_array[i]);
    
    	printf("how many bits rotation");
    	scanf("%d",&rotate);
    
    	for(i=0;i<rotate;i++)
    	{
    		if((saved_char&1)==1)
    			temp=1;
    		else
    			temp=0;
    
    		saved_char>>=1;
    		
    		saved_char|0x080;
    		
    	}
    
    	for(i=0;i<8;i++)
    	{
    		if((saved_char&1)==1)
    			rotate_array[i]=1;
    		else
    			rotate_array[i]=0;
    
    		saved_char>>=1;
    	}
    	printf("\nAfter rotation\n\n");
    
    	for(i=7;i>-1;i--)
    	{
    		printf("%d",rotate_array[i]);
    	}
    	
    	
    
    
    	getch();
    
    
    	return 0;
    }

  2. #2
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Code:
    saved_char|0x080;
    should become
    Code:
    saved_char |= 0x080;
    I belive.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  3. #3
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    You believe correctly. If you leave out the =, then it just evaluates the expression, but doesn't store the result anywhere. You need that = to make it store the result in the variable.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    70
    thanks dudes

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Type Writer Effect help please.
    By Fujitaka in forum C Programming
    Replies: 6
    Last Post: 02-01-2009, 10:11 AM
  2. New cloud effect for engine
    By VirtualAce in forum Game Programming
    Replies: 17
    Last Post: 02-08-2005, 03:23 AM
  3. How your grades effect your income
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 12-09-2004, 05:31 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. audio effect algorithms in c
    By jam1e1 in forum C Programming
    Replies: 4
    Last Post: 10-13-2001, 06:36 AM