在 cmd 中,我输入:gcc -v
来获取我的编译器版本,这就是我得到的
C:\Users\myStuff\Documents\C_Codes>gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe Target: mingw32 Configured with: ../gcc-4.8.1/configure
--prefix=/mingw --host=mingw32 --build=m ingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto
--enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++ ,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-l ibstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gm p-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld -- with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable- libgomp --enable-threads --with-libiconv-prefix=/mingw32
--with-libintl-prefix=/ mingw --disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T Thread model: win32 gcc version 4.8.1 (GCC)
我查看了 c:\minGW\include\以尝试找到 string.h 并且它在那里但是当我尝试让我的 C 代码类似于:
字符串温度
我得到以下编译错误:
错误:未知类型名称“string”
我该如何解决这个问题以便我可以使用字符串??
我还包含了stdio.h、stdlib.h,还有两个字符串头,string.h和strings.h
最佳答案
尝试使用g++
编译代码,因为c
语言不支持string
类型,否则你可以使用字符数组相同。
您可以像这样定义字符数组并将内容复制到数组中
char arr[SIZE];
strcpy(arr,"Your String");
关于c - 在 C 中使用 string.h 字符串对象时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24624109/