1. 解释“invalid types ‘char[int]’ for array subscript”错误的含义 “invalid types ‘char[int]’ for array subscript”这个错误意味着在尝试使用数组下标访问一个数组元素时,下标的类型不正确。在C或C++等编程语言中,数组下标必须是整型(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...
[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")...
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 ...
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
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...
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...
C++中的动态数组是以动态内存分配来实现的,即用new和delete动态分配和删除数组空间,所以像int Rev[len];这样的定义是非法的。根据楼主说的main函数中可以编译,那可能是在main函数中,len被赋予了常量,这样C++能够根据语法判断出实际是类似于int Rev[10]这样的定义,所以是可以编译通过的。但是在函数...
char marka[50] = "AUDI"; char model[50] = "R8 SPYDER"; int obujam[50] = {5204}; int masa[50] = {1720}; int max_snaga_kw[50] = {386}; int max_snaga_ks[50] = {535}; int max_brzina[50] = {313}; float ubrzanje[50] = {4.1}; ...