Hi, iam writing a pig latin program with 3 different methods

i dont knw understand the error that iam gettin in the code

here's the code:

#include <stdio.h>                 /*Include the standard I/0 header file */
#include <string.h>                /*Include the standard I/0 header file string library */

//The functions that are meant to be defined
char* toPLString(char * inputstring); 
int getInputBygetChar(char input[]);
int getInputByfgets(char input[]);
int getInputByscanf(char input[]);

       
int main(int argc, char *argv[]){
    char phrase[1000];
    char *token;
    printf("%s", getInputByscanf);
    printf("The sentence in Pig Latin is: ");
    token = strtok(phrase, " ");
    toPLString(token);
    printf("\n");

    system("Pause");
    return 0;
}
//method to convert to Pig Latin
char* toPLString(char * inputstring){
     char *toPLString = inputstring;
     while (toPLString != NULL){
           printf("%s%c%s", toPLString + 1, toPLString[0], "ay ");
           toPLString = strtok(NULL, " ");
           printf(" ");
     }
}

//Method to to read a string from keyboard and return number of characters read.
getInputBygetChar(char input[]){

}

//Method that uses the fgets method to read a string from keyboard and return number of characters read.
int getInputByfgets(char input[]){
    
}

/*Method that uses the scanf method to read a string from keyboard and return number of characters read.
*Scanf reads a character string. The scan terminates at whitespace. A null character is stored at the end
of the string. However, the input string size from a user is arbitrary.*/
int getInputByscanf(char input[]){
     char phrase;
     printf("\nEnter the phrase to translate: ");
     scanf("%s", &phrase);
     return 0;

    
}

i dont understand y its giving me the address output, i need to implement this method correctly, can some1 help me plzz...

alrite, cheers, here is the proper code

#include <stdio.h>                 /*Include the standard I/0 header file */
#include <string.h>                /*Include the standard I/0 header file string library */

//The functions that are meant to be defined
char* toPLString(char * inputstring); 
int getInputBygetChar(char input[]);
int getInputByfgets(char input[]);
int getInputByscanf(char input[]);

       
int main(int argc, char *argv[]){
    char phrase[1000];
    char *token;
    printf("%s", getInputByscanf);
    printf("The sentence in Pig Latin is: ");
    token = strtok(phrase, " ");
    toPLString(token);
    printf("\n");

    system("Pause");
    return 0;
}
//method to convert to Pig Latin
char* toPLString(char * inputstring){
     char *toPLString = inputstring;
     while (toPLString != NULL){
           printf("%s%c%s", toPLString + 1, toPLString[0], "ay ");
           toPLString = strtok(NULL, " ");
           printf(" ");
     }
}

//Method to to read a string from keyboard and return number of characters read.
getInputBygetChar(char input[]){

}

//Method that uses the fgets method to read a string from keyboard and return number of characters read.
int getInputByfgets(char input[]){
    
}

/*Method that uses the scanf method to read a string from keyboard and return number of characters read.
*Scanf reads a character string. The scan terminates at whitespace. A null character is stored at the end
of the string. However, the input string size from a user is arbitrary.*/
int getInputByscanf(char input[]){
     char phrase;
     printf("\nEnter the phrase to translate: ");
     scanf("%s", &phrase);
     return 0;

    
}

Ok, what were you trying acomplish with this:
>printf("%s", getInputByscanf);

First, that getInput... is function, so you have to call it with "()" brackets.
But still, it's nonesence

And there is a problem is getInputByscanf() function!
HINT: you can't assing string (%s) to char!
What is char input[] for?

i still dont get it, i'm calling getInputByscanf() in the main method, bt im not getting a correct output, iam getting some wierd output...

That's because of my other post. You don't do nothing with string that you pass to that function.

Hi,
Its all done wrong, have given the comments inside...

#include <stdio.h>                 /*Include the standard I/0 header file */
#include <string.h>                /*Include the standard I/0 header file string library */
 
//The functions that are meant to be defined
char* toPLString(char * inputstring); 
int getInputBygetChar(char input[]);
int getInputByfgets(char input[]);
int getInputByscanf(char input[]);
 
 
int main(int argc, char *argv[]){
    char phrase[1000];
    char *token;

/* Calling this function getInputByscanf will not get you back the string read from that function. The function call is wrong, the argument is missing */

printf("%s", getInputByscanf);

    printf("The sentence in Pig Latin is: ");

/* You are trying to strtok the string phrase[] which has nothing in it at this point */

token = strtok(phrase, " ");
    toPLString(token);
    printf("\n");
 
    system("Pause");
    return 0;
}
//method to convert to Pig Latin
char* toPLString(char * inputstring){
     char *toPLString = inputstring;
     while (toPLString != NULL){
           printf("%s%c%s", toPLString + 1, toPLString[0], "ay ");
           toPLString = strtok(NULL, " ");
           printf(" ");
     }
}
 
//Method to to read a string from keyboard and return number of characters read.
getInputBygetChar(char input[]){
 
}
 
//Method that uses the fgets method to read a string from keyboard and return number of characters read.
int getInputByfgets(char input[]){
 
}
 
/*Method that uses the scanf method to read a string from keyboard and return number of characters read.
*Scanf reads a character string. The scan terminates at whitespace. A null character is stored at the end
of the string. However, the input string size from a user is arbitrary.*/
int getInputByscanf(char input[]){
     char phrase;
     printf("\nEnter the phrase to translate: ");

/* phrase is a cahracter and not a string, using %s is incorrect. More over this variable is local to this function it will not be reflected back to the called function */

scanf("%s", &phrase);
     return 0;

this is interesting

char* toPLString(char * inputstring){
     char *toPLString = inputstring;
     ....
}

your function and your pointer have the same name :?:

and the end of your string is '\0' not NULL.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.