Thread: Stupid Question Probably

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    9

    Stupid Question Probably

    i got a question lets say this program for example.

    Code:
    #include <stdio.h>
    
    int main(void){
    		signed int foo = 1;
    		
    		printf("foo is %i", foo);
    		return 0;
    }
    isn't it that same as

    Code:
    #include <stdio.h>
    
    int main(void){
    		int foo = 1;
    		
    		printf("foo is %i", foo);
    		return 0;
    }
    cause int is signed and the only way it would be different is unsigned so wouldn't it be better to just use int foo = 1; instead of signed int foo = 1;?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Yes, int's are always signed unless you say unsigned.

    The same is not true for chars, which may be signed or unsigned (by default)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    9
    yeah i know that char care different so its really useless to use signed int foo; cause its signed by default right?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Question
    By Dave3of5 in forum C++ Programming
    Replies: 7
    Last Post: 05-24-2006, 03:52 PM
  2. Replies: 7
    Last Post: 11-04-2005, 12:17 AM
  3. Stupid Question
    By digdug4life in forum C++ Programming
    Replies: 22
    Last Post: 05-17-2005, 11:43 AM
  4. stupid, stupid question
    By xelitex in forum C++ Programming
    Replies: 5
    Last Post: 12-22-2004, 08:22 PM
  5. Stupid question: What does Debugger do?
    By napkin111 in forum C++ Programming
    Replies: 6
    Last Post: 05-02-2002, 10:00 PM