Dec 7, 2012 at 12:51am UTC
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
// Programi Kodi
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
const int m=8, n=8;
double A[m][n], c;
int C = 1 ;
int i,j;
for (i=0; i<m; i++)
{
switch (i)
{
case (0):
{
for (j=0; j<n; j++)
{
A[i][j]= c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
}
case (1):
{
for (j=0;j<(n-1);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
case (2):
{
for (j=0;j<(n-2);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
}
case (3):
{
for (j=0;j<(n-3);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
}
case (4):
{
for (j=0;j<(n-4);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
}
case (5):
{
for (j=0;j<(n-5);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
}
case (6):
{
for (j=0;j<(n-6);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
}
case (7):
{
for (j=0;j<(n-7);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
}
return 0;
}
Guys, i really need u're help. I'm new at programming thing so i write this thing last night at Visual Studio 2005 and it shows me this:
" fatal error C1075: end of file found before the left brace '{' at ' "
Can anyone help me urgently, i need this because i'm a student!
Thanks indeed!
Last edited on Dec 7, 2012 at 1:00am UTC
Dec 7, 2012 at 12:55am UTC
use code blocks so we can read this easier.
the error is saying you have an extra '}' somewhere, but i dont feel like going through that messy code to find it.
surround the code with [.code][./code] without the '.'
Dec 7, 2012 at 12:57am UTC
how can i do that? please forgive me but i'm using visual studio 2005
Dec 7, 2012 at 1:00am UTC
I fixed it! What about now?
Dec 7, 2012 at 1:04am UTC
well, it still pretty hard to read formatting lol. What i do notice is that you have braces around your cases. Those are unnecessary and may be causing the problem.
It would be much easier to read if it were formatted like this:
1 2 3 4
if ( ..conditional... )
{
// one indentation
}
or with the open brace after the '(' if you like.
EDIT: i dont think your forloop has an end brace
Last edited on Dec 7, 2012 at 1:04am UTC
Dec 7, 2012 at 1:06am UTC
Man, i'm not really understaning u. Can u copy the code and fix there and bold for me, cuz i told u i'm a really amateur in this stuff!
Dec 7, 2012 at 1:10am UTC
This has not been tested.
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
// Programi Kodi
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
const int m=8, n=8;
double A[m][n], c;
int C = 1 ;
int i,j;
for (i=0; i<m; i++)
{
switch (i)
{
case (0):
for (j=0; j<n; j++)
{
A[i][j]= c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
case (1):
for (j=0;j<(n-1);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
case (2):
for (j=0;j<(n-2);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
case (3):
for (j=0;j<(n-3);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
case (4):
for (j=0;j<(n-4);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
case (5):
for (j=0;j<(n-5);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
case (6):
for (j=0;j<(n-6);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
case (7):
for (j=0;j<(n-7);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
}// end switch
}// end for loop
return 0;
}// end main
Last edited on Dec 7, 2012 at 1:11am UTC
Dec 7, 2012 at 1:11am UTC
I cleaned up your indentation a bit and the problems became obvious. This code is a study in why proper and consistent style MATTERS.
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
// Programi Kodi
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
const int m=8, n=8;
double A[m][n], c;
int C = 1 ;
int i,j;
for (i=0; i<m; i++)
{
switch (i)
{
case (0):
{
for (j=0; j<n; j++)
{
A[i][j]= c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
}
case (1):
{
for (j=0;j<(n-1);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
} // you were missing this brace for case(1)
case (2):
{
for (j=0;j<(n-2);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
}
case (3):
{
for (j=0;j<(n-3);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
}
case (4):
{
for (j=0;j<(n-4);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
}
case (5):
{
for (j=0;j<(n-5);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
}
case (6):
{
for (j=0;j<(n-6);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
}
case (7):
{
for (j=0;j<(n-7);j++)
{
A[i][j]=c;
c =c+1;
cout << A[i][j];
}
cout << endl ;
break ;
}
} // missing this brace for the switch
} //missing this brace for the for
return 0;
}
You were missing 3 braces, the locations of which I commented in the code.
Edit: *sigh* and copying from Code::Blocks to here messed up indentation some too.
Edit2: Nano was right, you need breaks, added them.
Last edited on Dec 7, 2012 at 1:21am UTC
Dec 7, 2012 at 1:11am UTC
have i have tu use BREAK;
and end main while i test it?
Dec 7, 2012 at 1:14am UTC
If you dont use a break statement, all of the next cases will also be run. The break statement stops that from happening.
Dec 7, 2012 at 1:17am UTC
How can i open this in cmd, i mean whith which commands.
P.S. I have saved this at my Documents.
Dec 7, 2012 at 1:17am UTC
You should really be using a compiler bro.
Dec 7, 2012 at 1:28am UTC
Using VC++ just select Debug->Start Without Debugging or hit CTRL + F5. Both will build the program then run it.
Dec 7, 2012 at 1:29am UTC
i saved this like ushtrimi 1, to run do i have to write ushtrimi1.exe or how??
Dec 7, 2012 at 1:29am UTC
Oh well the .exe is in the debug folder of the project if i remember correctly.
To run it from the cmd prompt try:
c:\your_file_path \debug\file.exe
edit: I am very confused. Are you just trying to see it work anyway possible? Try looking under debug for something like start debugging.
Last edited on Dec 7, 2012 at 1:31am UTC
Dec 7, 2012 at 1:34am UTC
"'ushtrimi 1.exe': Loaded 'C:\Users\Trashegim\Documents\Visual Studio 2005\Projects\ushtrimi 1\debug\ushtrimi 1.exe', Symbols loaded.
'ushtrimi 1.exe': Loaded 'C:\Windows\System32\ntdll.dll', No symbols loaded.
'ushtrimi 1.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', No symbols loaded.
'ushtrimi 1.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', No symbols loaded.
'ushtrimi 1.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc80.debugcrt_1fc8b3b9a1e18e3b_8.0.50727.42_none_ef74ff32550b5bf0\msvcp80d.dll', Symbols loaded.
'ushtrimi 1.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc80.debugcrt_1fc8b3b9a1e18e3b_8.0.50727.42_none_ef74ff32550b5bf0\msvcr80d.dll', Symbols loaded.
'ushtrimi 1.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', No symbols loaded.
The program '[2640] ushtrimi 1.exe: Native' has exited with code 0 (0x0).
"
I clikced debuggin and it shows me this. Is is good or what :$
Dec 7, 2012 at 1:40am UTC
I have absolutely no idea what is going on with this now. I've never had a problem running a program within VC++ 2010 like this. Did you start a new Win32 console project and put the code inside the main.cpp file?
Last edited on Dec 7, 2012 at 1:41am UTC
Dec 7, 2012 at 1:41am UTC
Looks okay to me. Did a black box open and close? If you arent sure debug it again.