使用post方法和参数进行Redirect_to

时间:2016-12-10 17:14:38

标签: ruby-on-rails ruby-on-rails-4 rubygems

如何redirect_to 'example.com?key=value&key=value' # with post method 用户使用发布方法和参数?

喜欢这段代码:

#include <stdio.h>
#include <string.h>

int main ()
{
    char file_path[40] = { 0 }, stf[255] = { 0 }, rtf[255] = { 0 }, str[255] = { 0 };
    FILE* file = NULL;
    FILE *e_f;

    if((e_f=fopen("result.txt","w"))==NULL){
        printf("ERROR\n");
        exit(1);
    }

    do
    {
    printf("Enter file path: ");
    fgets(file_path, 40, stdin);
    file_path[strlen(file_path) - 1] = '\0';
    file = fopen(file_path, "r+");
    }

    while(file == NULL);

    printf("Enter text to find: ");
    fgets(stf, 255, stdin);
    stf[strlen(stf) - 1] = '\0';
    printf("Enter text to replace: ");
    fgets(rtf, 255, stdin);
    rtf[strlen(rtf) - 1] = '\0';

    while(fgets(str, 255, file) != NULL)
    {
    char* tmp_ptr = strstr(str, stf);
    while(tmp_ptr != NULL)
    {
        char tmp_str[255];
        strcpy(tmp_str, tmp_ptr + strlen(stf));
        strcpy(str + strlen(str) - strlen(tmp_ptr), rtf);
        strcat(str, tmp_str);
        tmp_ptr = strstr(str, stf);
    }
    printf("%s", str);
    }
    fclose(file);
    fclose(e_f);

    return 0;
}

0 个答案:

没有答案