obviously you can initialize a single array like this
but if you had a big array that needed to be initialized at declaration time how do you span multiple likes rather than one long stringCode:int myarray[5] = { 1, 2, 3, 4, 5 };
obviously you can initialize a single array like this
but if you had a big array that needed to be initialized at declaration time how do you span multiple likes rather than one long stringCode:int myarray[5] = { 1, 2, 3, 4, 5 };
Everywhere you have a white space, you can have a newline.
You can do the same with strings also.Code:int myarray[5] = { 1, 2, 3, 4, 5 };
Code:char text[] = "The quick brown fox " "jumps, over the lazy dog!";
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
thanks they are about the only combinations i didn't try
Are you trying to read the cipher data into an array? If so, instead of hard-coding it into your program text, you can read it directly from the file like this:
Code:#include <stdio.h> #include <stdlib.h> #define INPUTFILE "cipher.txt" int get_text(char *text) { FILE *file = fopen(INPUTFILE, "r"); if (!file) { perror(INPUTFILE); exit(EXIT_FAILURE); } int len = 0; // The %*c reads and ignores the comma after the integer. for (int ch; fscanf( file, "%d%*c", &ch ) == 1; ) text[len++] = ch; fclose(file); return len; } int main() { char text[1500]; // Input has 1455 chars int len = get_text(text); printf("%d\n", len); // should print 1455 return 0; }
A little inaccuracy saves tons of explanation. - H.H. Munro
thanks you read my mind i was getting to the point of cut and paste and having it as a fixed array