Stupid Question Probably

This is a discussion on Stupid Question Probably within the C Programming forums, part of the General Programming Boards category; i got a question lets say this program for example. Code: #include <stdio.h> int main(void){ signed int foo = 1; ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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-03-2005, 11:17 PM
  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, 07: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21