Sunday, July 26, 2009

Is it possible to store more than 127 characters in a character array in C?

#include%26lt;stdio.h%26gt;


#include%26lt;string.h%26gt;


//Iinclude files...





// other functions





void main(int argc, char *argv)


{


char input;


//I tried input[] and input[200];


printf("Enter input");


scanf("%s",%26amp;input); // I also tried gets(%26amp;input)


/*


HERE FOLLOWS OTHER CODE


*/


}








- - - -- -- - - - - - -- - - -- - - - - - - -- -- - - - - - -- - - -- - - - -


Here lies the problem, I am unable to type more than 127 chars in the command prompt. I know it is long but i want it for some purpose.


I also once tried wheter it works if I initialize the string in the code itself. But that also didnt work.





Some more details:


Compiler : Turboc3,Turboc3


OS: XP Pro, 98SE


Ram: 256 MB





Is it not possible to store more than 128 ( including \0 ) chars in C?

Is it possible to store more than 127 characters in a character array in C?
You can store as many characters in an C array as you want.





Also I suggest you change to djgpp if you something similar to turbo c++. TUrbo C++ 3 is more or less dead and was ment for DOS only. Other alternates are VC 6, GCC on Linux, GCC using cygwin on windows.





There are some errors in the code you posted along with your question.





It should be





char input[1000];


gets(input);





and not gets(%26amp;input)


Same is the case with scanf





Since the name of an arrey itself is a pointer you need not send address of pointer.
Reply:yes, upgrad to/get a mac and you can have up to 1024*512*256*128*64*32*16*8*4*2*1 char's in a array

daisy

No comments:

Post a Comment