小编Qut*_*uto的帖子

strcasestr 仍然无法正常工作

所以我通读了其他问题,他们被告知放在#define _GNU_SOURCE任何包含之前,它会起作用,但对我不起作用。我也尝试添加#define _GNU_SOURCE char *strcasestr(const char *haystack, const char *needle);但仍然不起作用。我找不到关于此的任何其他信息,也许有人可以提供帮助?提前致谢。

错误:函数“strcasestr”的隐式声明

/**
 *
 * Description:  This is code for Lab 3 Task 2.
 *               Reads data from file and gives opportunity to search by cities
 */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

    printf("Please input the city you want to find employees in:");
    scanf("%s", input);
    maxline = i;
    for (i = 0; i <= maxline; i++) {
        if (strcasestr(employee[i].city, input) != 0) { // PROBLEM …
Run Code Online (Sandbox Code Playgroud)

c string

5
推荐指数
1
解决办法
1379
查看次数

为什么我不能在功能中第二次声明结构?

所以,我得到了一个函数,我声明一个已填充的结构,并且还要声明一个新函数.当我在顶部声明新函数时它起作用,当我在逗号(,)之后将它声明在同一行时,它可以工作,但它不适用于底线.有什么解释吗?提前致谢.

void CFilter(float avgprofit, int lines)
{
    //client goodclient[MAX_CLIENT]; THIS WOULD COMPILE
    client client[MAX_CLIENT], goodclient[MAX_CLIENT]; // THIS COMPILES
    //client goodclient[MAX_CLIENT]; THIS WOULDN'T COMPILE
    int i, amount = 0;
    float userprofit;
    for (i = 0; i <= lines; i++) {
        userprofit = client[i].loses - client[i].wins;
        if (userprofit >= avgprofit) {
            client[i].goodclient = 1;
        } else {
            client[i].goodclient = 0;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c struct compiler-errors declaration

2
推荐指数
1
解决办法
65
查看次数

C - 如何在组中对一维数组中的数字进行排序?

我有一个数组,我需要在组中对该数组中的数字进行排序.例如,如果我有9个数字而我的P是3,我需要按降序排序三个数字然后另外3个和另外3个.

例:

123 124 125 222 223 224 333 334 335

M是组数,P是组中的数量.如果M是3而P也是3则需要给出答案

125 124 123 224 223 222 335 334 333

这是我提出的,但它不起作用.

void sortgroup(int M, int P, int A[i])
{
      int c, d, swap, z = 0;
      for (c = z ; c < ( P*M - 1 + z ); c++)
      {
        for (d = z ; d < P + z - 1; d++)
        {
          if (A[d] < A[d+1])
          {
            swap       = A[d];
            A[d]   = A[d+1];
            A[d+1] = …
Run Code Online (Sandbox Code Playgroud)

c arrays sorting

0
推荐指数
1
解决办法
161
查看次数

标签 统计

c ×3

arrays ×1

compiler-errors ×1

declaration ×1

sorting ×1

string ×1

struct ×1