1. 解释“invalid types ‘char[int]’ for array subscript”错误的含义 “invalid types ‘char[int]’ for array subscript”这个错误意味着在尝试使用数组下标访问一个数组元素时,下标的类型不正确。在C或C++等编程语言中,数组下标必须是整型(int)类型。如果出现这个错误,通常意味着你使用了非整型的表达式作为数...
void red(int n,int m,char *a1)char a1 --> char *a1;穿的是地址!void red(int n,int m,char *a1){ char *p;int i;p=&a1[m-1];for( i=0;i<m;i++,p++){printf("%c",*p);} }
Hello, I have this code that gives me the error from the title: This is problem statement: Given a string of "s" consisting of two words separated by space (first
[Error] invalid types 'char[int]' for array subscript #include <stdio.h> #include <stdlib.h> int main() { char a[20]; char out[9]; int i,m,n; FILE *fp; printf("请输入20个单词:\n"); gets(a); if((fp=fopen("e:\\1.txt","w"))==NULL) { printf("文件打开失败!\n")...
In function 'int main()': Line 52: error: invalid types 'char[int]' for array subscript compilation terminated due to -Wfatal-errors. Any ideas? Jun 5, 2013 at 2:02am vlad from moscow(6539) You defined heshecaps as a single character. So you may not use the subscript operator with...
invalid types `char[int]' for array subscript 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include <iostream>#include <stdio.h>usingnamespacestd;intmain () {intplayer;//Assign player numberdoubleH;//Assign variable for hitsdoubleO;//Assign ...
max函数中array变量是int*类型,它是int数组bai,后面只能一个下标,写了多处array[I][j],当做二维数组来用。max函数最后一个for循环,for循环应该有三部分,它们以分号隔开,这里只有一部分,没有分号隔开。include <iostream> using namespace std;int max(int (*array)[100],int I,int J,int...
#include <iostream> using namespace std; class Book{ // declaring private class data members private: char book_name[50]; float book_price; int bookid; char author[20]; bool available; int year; public: // declaring constructor Book() { cout<<"Default constructor is called"<<endl; nam...
根据楼主说的main函数中可以编译,那可能是在main函数中,len被赋予了常量,这样C++能够根据语法判断出实际是类似于int Rev[10]这样的定义,所以是可以编译通过的。但是在函数中,上述定义是不行的,因为函数调用时,编译器无法判断传递来的参数是否是编译期的常量,这样就构成了动态数组的定义,这在C++中...
: error: invalid types `int[int]' for array subscript for(inti=1;i<=N;i++){if(Sl[i]>=m&&Sl[i]<n)n=Sl[i];}... for(int i=1;i<=N;i++) { if(Sl[i]>=m&&Sl[i]<n) n=Sl[i]; } 展开 C++不支持动态数组,比如像Basic中的Redim,Pascal中的SetLength等C++中的