小编Nyx*_*yxm的帖子

C中数组的最大大小是多少?

我知道硬件将限制程序执行期间分配的内存量.但是,我的问题是不考虑硬件.假设内存量没有限制,那么阵列没有限制吗?

c arrays

45
推荐指数
4
解决办法
12万
查看次数

GCC编译错误:格式'%c'需要类型'char*'的参数,但参数2的类型为'int'[-Wformat]

好吧,我是C的菜鸟,但我认为代码是基本的,直截了当的.该程序适用于大学作业,并且应该具有'isdigit()'功能.这是代码

//by Nyxm
#include <stdio.h>
#include <ctype.h>

main()
{
    char userChar;
    int userNum, randNum;
    srand(clock());
    printf("\nThis program will generate a random number between 0 and 9 for a user to guess.\n");
    /*I changed it from '1 to 10' to '0 to 9' to be able to use the isdigit() function which
    will only let me use a 1 digit character for an argument*/
    printf("Please enter a digit from 0 to 9 as your guess: ");
    scanf("%c", userChar);
    if (isdigit(userChar))
    { …
Run Code Online (Sandbox Code Playgroud)

c gcc char

6
推荐指数
1
解决办法
1万
查看次数

在C中程序完成时暂停屏幕

我希望能够Press any key to exit在程序完成时做一些事情,但却无法弄清楚如何.

当我运行程序时,终端退出后才能看到结果.

//by Nyxm
#include <stdio.h>

main() {

    int temp, x, flag, num, size;

    printf("\nEnter how many numbers you wish to enter: ");
    scanf("%d", &size);
    int array[size];

    for (x = 0; x < size; x++) {
        printf("Enter an integer: ");
        scanf("%d", &num);
        array[x] = num;
    }

    printf("Please enter either 1 or 2\n1:\tAscending\n2:\tDescending\n\n...");
    scanf("%d", &num);

    if (num == 1) {
        flag = 0;
        while (flag == 0) {
            flag = 1;
            for (x = 1; …
Run Code Online (Sandbox Code Playgroud)

c

2
推荐指数
2
解决办法
8万
查看次数

C#中的System.FormatException

我继续在我尝试为销售变量分配值的每一个案例中获得FormatException.谁知道我做错了什么?我应该把这个控制台程序作为学习循环的作业,但我发现更多关于其他事情.它应该按照每次销售的10%佣金保持销售人员佣金的运行标签.无论如何,这里是代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TubSales
{
   class Program
   {
      static void Main(string[] args)
      {
         char initial;
         const double COMM_INT = 0.10;
         double sale, aComm = 0, bComm = 0, eComm = 0;
         Console.Write("Enter 'A' for Andrea, 'B' for Brittany,\n'E' for Eric, or 'Z' to quit >> ");
         initial = Convert.ToChar(Console.Read());
         while (initial != 'z' && initial != 'Z')
         {
            switch (initial)
            {
               case 'a':
               case 'A':
                  Console.Write("Enter the sales for Andrea >> ");
                  sale …
Run Code Online (Sandbox Code Playgroud)

c# formatexception

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

标签 统计

c ×3

arrays ×1

c# ×1

char ×1

formatexception ×1

gcc ×1