Tuesday, December 05, 2017
Tuesday, October 24, 2017
ch8 ex 13 data file
Johnson 85 83 77 91 76
Aniston 80 90 95 93 48
Cooper 78 81 11 90 73
Gupta 92 83 30 69 87
Blair 23 45 96 38 59
Clark 60 85 45 39 67
Kennedy 77 31 52 74 83
Bronson 93 94 89 77 97
Sunny 79 85 28 93 82
Smith 85 72 49 75 63
Output file:
Aniston 80 90 95 93 48
Cooper 78 81 11 90 73
Gupta 92 83 30 69 87
Blair 23 45 96 38 59
Clark 60 85 45 39 67
Kennedy 77 31 52 74 83
Bronson 93 94 89 77 97
Sunny 79 85 28 93 82
Smith 85 72 49 75 63
Output file:
Name Test 1 Test 2 Test 3 Test 4 Test 5 Average Grade Johnson 85.00 83.00 77.00 91.00 76.00 82.40 B Aniston 80.00 90.00 95.00 93.00 48.00 81.20 B Cooper 78.00 81.00 11.00 90.00 73.00 66.60 D Gupta 92.00 83.00 30.00 69.00 87.00 72.20 C Blair 23.00 45.00 96.00 38.00 59.00 52.20 F Clark 60.00 85.00 45.00 39.00 67.00 59.20 F Kennedy 77.00 31.00 52.00 74.00 83.00 63.40 D Bronson 93.00 94.00 89.00 77.00 97.00 90.00 A Sunny 79.00 85.00 28.00 93.00 82.00 73.40 C Smith 85.00 72.00 49.00 75.00 63.00 68.80 D
Tuesday, October 10, 2017
Tuesday, September 05, 2017
Thursday, July 20, 2017
Unknown Error
If you get the Unknown Error with MS Visual Studio 2017 do thi:
I have a same problem after update VS 2017 Enterprise to the build 26228.9.
Repair installation doesn't fix anything. Still I got "Unknown error" message immediately after start VS2017.
Fixing is possible by removing this folder:
"C:\Users\USER_NAME\AppData\Local\Microsoft\VisualStudio\15.0_xxxxxxx"
Tuesday, July 18, 2017
Monday, July 17, 2017
Thursday, June 01, 2017
Wednesday, May 31, 2017
Thursday, April 27, 2017
In c++ the dot is an operator, what does it do
when you pass the if or of stream to a variable as a function how do you pass it
what do you put in front of a logical expression to reverse its value
4 choices: only one of them is a reserve word
++ operator : preincrement and postincrement:
Int a = 0
Int b = 0
B = ++A; means 1 is added to A then B becomes A: Preoperator
B = A++; means B becomes A then 1 is added to A: Postoperator
what is a valid char?
7 fill in the blanks, rest are multiple choice, total of 32 questions.
question 13 may want to use the compiler
For loop printing out the values of an array
DO you know the length of a string from looking at it?
calling conventions: two perspectives of a function: formal or actual: perspective
of the caller or the perspective of the called
static_cast{int}
two dimensional array
index operators
Member access specifier for a class
Inheritance: Base class and derived class?
which of the following class definitions makes the public members of the class A
class become the public members of the class B class
Question 26: Series of expressions: which one will evaluate to true? pick the one
that is ALWAYS true
Test does end with true or false questions actually
enum: understand the syntax
what is Macgyver's first name?
TO develop a program to solve a problem, you start by analyzing the problem.
when you pass the if or of stream to a variable as a function how do you pass it
what do you put in front of a logical expression to reverse its value
4 choices: only one of them is a reserve word
++ operator : preincrement and postincrement:
Int a = 0
Int b = 0
B = ++A; means 1 is added to A then B becomes A: Preoperator
B = A++; means B becomes A then 1 is added to A: Postoperator
what is a valid char?
7 fill in the blanks, rest are multiple choice, total of 32 questions.
question 13 may want to use the compiler
For loop printing out the values of an array
DO you know the length of a string from looking at it?
calling conventions: two perspectives of a function: formal or actual: perspective
of the caller or the perspective of the called
static_cast{int}
two dimensional array
index operators
Member access specifier for a class
Inheritance: Base class and derived class?
which of the following class definitions makes the public members of the class A
class become the public members of the class B class
Question 26: Series of expressions: which one will evaluate to true? pick the one
that is ALWAYS true
Test does end with true or false questions actually
enum: understand the syntax
what is Macgyver's first name?
TO develop a program to solve a problem, you start by analyzing the problem.
Tuesday, April 11, 2017
Tuesday, February 28, 2017
MidTerm Review Spring 2017
9 t/f
20 multiple choice
• char extraction operator (>>) how it behaves.
• flag control while loop do you use bool value? yes
• while loop ( ) <----- div="">
• how many times does a for loop execute/iterate. for(int i = 1; i<5 4="" div="" false="" i="" is="" so="" times.="" whenever="">
5>
----->
• know pre and post ++x(pre)/x++(post)
o ex.1
o x = 5;
o x++ = 5 //x = 6
o ++x= 7
o ex.2 a = 1;
o b = 0;
o b = ++a;
o a = 2;
o b = 2 ;
o -------------
o b = a++;
o b = 1;
• prototyping a function:
• #include
• using namespace std;
• void protoTypedFunction(int,int); the prototype
• know what an infinite loop is:
o ex: while(true)
• A while loop tell the output of it.
• Part of dev environment combines our pro./prog. from - assembler linker, decoder, complier.
• Know this something:
o cin >> x >> y;
o stdin: 5, 6; x = 5 y = 6
• interger division
• 19 / 7 = 2
• length of a string.
o string name = "Billy"
o length = 5
• cout << pow(pow(num, num), number) << endl;
o pow = power operator from cmath/math.h.
o pow(9,3) = 9^3 = 9 * 9 * 9
• Pre increment operation example. Break it down into 2 steps.
• Ifstream <--- 160.="" a="" div="" file.="" opening="" page="">
• Ascii has 128 characters
o Other one has 255 characters.
o Unicode has 65535 characters
--->Tuesday, January 24, 2017
Tuesday, November 15, 2016
WinSock Server
// WinSockServer.cpp : Defines the entry point for the console application. // #include "stdafx.h" #undef UNICODE #define WIN32_LEAN_AND_MEAN #include#include #include #include #include // Need to link with Ws2_32.lib #pragma comment (lib, "Ws2_32.lib") // #pragma comment (lib, "Mswsock.lib") #define DEFAULT_BUFLEN 512 #define DEFAULT_PORT "27015" int __cdecl main(void) { WSADATA wsaData; int iResult; SOCKET ListenSocket = INVALID_SOCKET; SOCKET ClientSocket = INVALID_SOCKET; struct addrinfo *result = NULL; struct addrinfo hints; int iSendResult; char recvbuf[DEFAULT_BUFLEN]; int recvbuflen = DEFAULT_BUFLEN; // Initialize Winsock iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); if (iResult != 0) { printf("WSAStartup failed with error: %d\n", iResult); return 1; } ZeroMemory(&hints, sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; hints.ai_flags = AI_PASSIVE; // Resolve the server address and port iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result); if (iResult != 0) { printf("getaddrinfo failed with error: %d\n", iResult); WSACleanup(); return 1; } // Create a SOCKET for connecting to server ListenSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol); if (ListenSocket == INVALID_SOCKET) { printf("socket failed with error: %ld\n", WSAGetLastError()); freeaddrinfo(result); WSACleanup(); return 1; } // Setup the TCP listening socket iResult = bind(ListenSocket, result->ai_addr, (int)result->ai_addrlen); if (iResult == SOCKET_ERROR) { printf("bind failed with error: %d\n", WSAGetLastError()); freeaddrinfo(result); closesocket(ListenSocket); WSACleanup(); return 1; } freeaddrinfo(result); iResult = listen(ListenSocket, SOMAXCONN); if (iResult == SOCKET_ERROR) { printf("listen failed with error: %d\n", WSAGetLastError()); closesocket(ListenSocket); WSACleanup(); return 1; } // Accept a client socket ClientSocket = accept(ListenSocket, NULL, NULL); if (ClientSocket == INVALID_SOCKET) { printf("accept failed with error: %d\n", WSAGetLastError()); closesocket(ListenSocket); WSACleanup(); return 1; } // No longer need server socket closesocket(ListenSocket); // Receive until the peer shuts down the connection do { iResult = recv(ClientSocket, recvbuf, recvbuflen, 0); if (iResult > 0) { printf("Bytes received: %d\n", iResult); // Echo the buffer back to the sender iSendResult = send(ClientSocket, recvbuf, iResult, 0); iSendResult = send(ClientSocket, recvbuf, iResult, 0); if (iSendResult == SOCKET_ERROR) { printf("send failed with error: %d\n", WSAGetLastError()); closesocket(ClientSocket); WSACleanup(); return 1; } printf("Bytes sent: %d\n", iSendResult); } else if (iResult == 0) printf("Connection closing...\n"); else { printf("recv failed with error: %d\n", WSAGetLastError()); closesocket(ClientSocket); WSACleanup(); return 1; } } while (iResult > 0); // shutdown the connection since we're done iResult = shutdown(ClientSocket, SD_SEND); if (iResult == SOCKET_ERROR) { printf("shutdown failed with error: %d\n", WSAGetLastError()); closesocket(ClientSocket); WSACleanup(); return 1; } // cleanup closesocket(ClientSocket); WSACleanup(); return 0; }
WinSock Client
// WinSockClient.cpp : Defines the entry point for the console application. // #include "stdafx.h" #define WIN32_LEAN_AND_MEAN #include#include #include #include #include // Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib #pragma comment (lib, "Ws2_32.lib") #pragma comment (lib, "Mswsock.lib") #pragma comment (lib, "AdvApi32.lib") #define DEFAULT_BUFLEN 512 #define DEFAULT_PORT "27015" int __cdecl main(int argc, char **argv) { WSADATA wsaData; SOCKET ConnectSocket = INVALID_SOCKET; struct addrinfo *result = NULL, *ptr = NULL, hints; char *sendbuf = "this is a test"; char recvbuf[DEFAULT_BUFLEN]; int iResult; int recvbuflen = DEFAULT_BUFLEN; // Validate the parameters if (argc != 2) { printf("usage: %s server-name\n", argv[0]); return 1; } // Initialize Winsock iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); if (iResult != 0) { printf("WSAStartup failed with error: %d\n", iResult); return 1; } ZeroMemory(&hints, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; // Resolve the server address and port iResult = getaddrinfo(argv[1], DEFAULT_PORT, &hints, &result); if (iResult != 0) { printf("getaddrinfo failed with error: %d\n", iResult); WSACleanup(); return 1; } // Attempt to connect to an address until one succeeds for (ptr = result; ptr != NULL;ptr = ptr->ai_next) { // Create a SOCKET for connecting to server ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); if (ConnectSocket == INVALID_SOCKET) { printf("socket failed with error: %ld\n", WSAGetLastError()); WSACleanup(); return 1; } // Connect to server. iResult = connect(ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen); if (iResult == SOCKET_ERROR) { closesocket(ConnectSocket); ConnectSocket = INVALID_SOCKET; continue; } break; } freeaddrinfo(result); if (ConnectSocket == INVALID_SOCKET) { printf("Unable to connect to server!\n"); WSACleanup(); return 1; } // Send an initial buffer iResult = send(ConnectSocket, sendbuf, (int)strlen(sendbuf), 0); if (iResult == SOCKET_ERROR) { printf("send failed with error: %d\n", WSAGetLastError()); closesocket(ConnectSocket); WSACleanup(); return 1; } printf("Bytes Sent: %ld\n", iResult); // shutdown the connection since no more data will be sent iResult = shutdown(ConnectSocket, SD_SEND); if (iResult == SOCKET_ERROR) { printf("shutdown failed with error: %d\n", WSAGetLastError()); closesocket(ConnectSocket); WSACleanup(); return 1; } // Receive until the peer closes the connection do { iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0); if (iResult > 0) { recvbuf[iResult] = NULL; printf("Msg: %s\nBytes received: %d\n", recvbuf, iResult); } else if (iResult == 0) printf("Connection closed\n"); else printf("recv failed with error: %d\n", WSAGetLastError()); } while (iResult > 0); // cleanup closesocket(ConnectSocket); WSACleanup(); return 0; }
Wednesday, January 20, 2016
Wednesday, January 06, 2016
Tuesday, July 21, 2015
Wednesday, July 15, 2015
#include
using namespace std;
//cin demo with exception detection and quit
int main(void)
{
int n = 0;
char c;
while(cin)
{
cout << "Enter a int(q to quit): ";
cin >> n;
if(!cin)
{
cin.clear();
c=cin.peek();
if(c=='q')
break;
else
{
cout << "Oops try again\n";
cin.ignore(5000,'\n');
}
}
}
return 0;
}
using namespace std;
//cin demo with exception detection and quit
int main(void)
{
int n = 0;
char c;
while(cin)
{
cout << "Enter a int(q to quit): ";
cin >> n;
if(!cin)
{
cin.clear();
c=cin.peek();
if(c=='q')
break;
else
{
cout << "Oops try again\n";
cin.ignore(5000,'\n');
}
}
}
return 0;
}
Subscribe to:
Posts (Atom)