Thread: Char - function

  1. #1
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198

    Char - function

    When you have a function

    void print(char a);

    when you call it, print('b');

    Now, if you have a variable..

    char var;

    and car gets a value, is it okay to call the function
    print(var); ?

    because I havent been getting the results I want like that...
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  2. #2
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    you mean:
    Code:
    #include <stdio.h>
    
    void print (char c) {
    	printf("%c",c);
    }
    
    int main(void) {
    	char var;
    
    	printf("Enter a char: ");
    	var = getchar(); //dont forget after this, flush the input buffer
    	
    	//print the var..
    	print(var);
    	return 0;
    }
    What's the problem? maybe your var isn't getting a value correctly.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  5. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM