My function will not return a value(HELP)

This is a discussion on My function will not return a value(HELP) within the C Programming forums, part of the General Programming Boards category; This is my program, for now it is intended to compute permutations of any string entered, but the function ox ...

  1. #1
    Registered User
    Join Date
    Jun 2013
    Posts
    5

    Exclamation My function will not return a value(HELP)

    This is my program, for now it is intended to compute permutations of any string entered, but the function ox will not return the final x value. ox is the function that actually computes the permutations so the return of the x value is critical. Any help would be much appreciated, please keep in mind that I am very new to c programming so it it very likely that I am doing something very simple and basic wrong.

    Code:
    #include<stdio.h>
    #include<string.h>
    int ox(int x);
    
    
    int main()
    {
    int x;
    char input[10];
    scanf("%s", input);
    x=strlen(input);
    ox(x);
    printf("\n%d", x);
    getchar();
    getchar();
    }
    
    
    int ox(int x)
    {
    int a;
    int x1;
    int b;
    b=x;
    for(a=1;a!=b;a++)
    {
    x=(x*(b-a));
    }
    return x;
    }
    

  2. #2
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    My function will not return a value(HELP)
    It does return a value. You're not using it.
    Try
    Code:
    x = ox(x);
    printf("\n%d", x);
    Kurt

  3. #3
    Registered User
    Join Date
    Jun 2013
    Posts
    5
    Thank you very much, I figured I was doing something simple wrong

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 06-10-2013, 04:03 PM
  2. Function return
    By xboss in forum C Programming
    Replies: 10
    Last Post: 10-03-2012, 01:38 PM
  3. What would this function return
    By ganesh bala in forum C Programming
    Replies: 2
    Last Post: 01-30-2009, 01:02 AM
  4. return function
    By bazzano in forum C Programming
    Replies: 1
    Last Post: 05-20-2007, 09:12 AM
  5. Replies: 6
    Last Post: 04-09-2006, 04:32 PM

Tags for this Thread


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