Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <curl/curl.h>
- int main( void )
- {
- int a = 1, b, c;
- char post[1000];
- CURL *curl;
- CURLcode res;
- /* In windows, this will init the winsock stuff */
- curl_global_init( CURL_GLOBAL_ALL );
- /* get a curl handle */
- curl = curl_easy_init();
- if ( curl ) {
- // aqui é definido o formulario que recebera os dados da requisição (POST).
- curl_easy_setopt( curl, CURLOPT_URL, "http://127.0.0.1/triangulo.php" );
- while ( a > 0 ) {
- printf( "\nDigite os 3 lados do triangulo separados por espaco: " );
- scanf( "%d %d %d", &a, &b, &c );
- sprintf( post, "n1=%d&n2=%d&n3=%d", a, b, c ); //Aqui é definida as variaveis do POST
- curl_easy_setopt( curl, CURLOPT_POSTFIELDS, post );
- /* Perform the request, res will get the return code */
- res = curl_easy_perform( curl );
- if ( res != CURLE_OK ) // verifica se deu algum erro
- fprintf( stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror( res ) );
- }
- /* always cleanup */
- curl_easy_cleanup( curl );
- }
- curl_global_cleanup();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement