Variables must be declared at the top of the block. Move your declaration above the printf statement.
Also, you have an extra semicolon on line 61(EDIT: Though that seems to pass through ok, I guess it's optional).
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
I think you are just 'moving too fast'. Study the documentation, for example fopen_s() .
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
I think you are just 'moving too fast'. Study the documentation, for example fopen_s() .
Actually, for all the *_s functions -- stop using them. They are not standard which makes it very difficult to help you, and will make it difficult to write code if you need to use a different compiler.
And post the EXACT error messages, not a paraphrase. It helps us to seeexactly what the compiler says.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Actually, for all the *_s functions -- stop using them.
I would rephrase that a little
Actually, for all the *_s functions -- stop using themif you aim to write standards-compliant code. Otherwise, learn and use them (these functions exist for a good reason). Just be aware that these functions are available only with recent Microsoft's compilers.
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
I have one warning at line 77 that says temp is not initialized. Please show me where to fix this.
About swapping, you need to have abuffer for swapping the strings. A mere char * used as you intended is not enough (it would cause havoc if used). So, at the very least, change to
/*Swapping*/
/* 'temp' - a buffer for swapping the strings */
char temp[12];
strcpy_s(temp,12,array[j]);
strcpy_s(array[j],12,array[j+1]);
strcpy_s(array[j+1],12,temp);
You might use a #define to define the sizes of the char arrays, so that it would be consistent throughout the code. As of now there are buffers of sizes 10, 12, 20.
So maybe
#define STRING_BUFFER_SIZE 20
int main()
{
char input[STRING_BUFFER_SIZE], output[STRING_BUFFER_SIZE];
/* ... and so on */
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395