It should exit the while loop after hitting line 6. What happens however is that it goes into a perpetual loop and doesnt exit the while loop upon reading line 6.
What I did was changed the code to:
Code: while (lineread != "*") { getline(ifs,lineread); } and the input file to: 27 GC0123456 102905908801170-- 2034068010201360 3039077011601400 4043086012901400
[code]....
and finally it stops after line 6. In this case, merely changing the " " conditional character to a simple asterisk character "*" fixes the problem.
However I wish to keep the input text file as is with the newlines, so how do I make it exit the while loop when detecting a as a line?
I have a certain method of encrypting text. You get the first character of the word. For example in the word "hacker", you get 'h', and then you get the last character 'r'. The encrypted word until now is "hr". Then we get the same word with the 'h' and 'r' removed, now it's "acke". I do the same thing and get the first character 'a' and the last one 'e' and them to the encrypted word: it is now "hrae".
The left letters of the word are "ck", again we do the same thing and take the first character 'c' and the last character 'k' and and add them to the new encrypted word so it is "hraeck". The above word has an even number of characters and at the end had 2 characters left 'c' and 'k',first and last, in some cases of words with an odd number of characters, only one character is left! I'm completely lost on how to encrypt and decrypt this.
I own a code written in c++ that is used to connect the router using the WPS protocol, but has to be modified to operate in "registrar" mode and I do not know much about c++.
I am writing on C simple socket programs in Linux. I wrote client and server C programs. My client program is Code: #include<sys/socket.h>//for socket(), connect(), sendto() and recvform()
#include<sys/types.h> #include<netinet/in.h> #include<netdb.h> #include<stdio.h>// for printf() and fprintf()
[Code]....
I am just testing whether can connect or not. I run server program first and client later. But when I run client, it showed that "Address family not supported by protocol".
Is there any standard USB protocol which i can follow to send data to my embedded board(and vice versa). I have no clue on USB programming using c,is there any example code i could follow,
but how do you use an array as the condition, how will the code look?For example i want to write
Code:
string numbers[5] = {"one","two","three","four","five"}; numbers == "one" ? thumb : again; thumb and again will replace something else. Don't worry about them.
how do i say that if the numbers array is representing "one" then it replaces as "thumb", otherwise "again".
So I think I am having syntactical problem with my code.
Code: int main() { vector<int> ivec; int score; [Code] ....
I get an error from my compiler on the ?10th? line (Nested condition line) that says |19|error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'|
The purpose of the program is to take input and store it in a vector and then change the value to be between 1-6. I made this for the purpose of learning about nested conditional operations.
The program will be reading in a .csv file, so I need my program to be able to deal with values separated by commas. Is there a reason why it will not accept that conditional statement?
I'm playing with my final year project, building a game boy emulator in C, and I wanted to try out something to streamline my code base. I'm building against Win32, GNU C and Googles Native Client.There are no platform specific headers or functions in use. What I'm trying to do is have a file that conditionally includes the entry point (so _tmain for Windows etc) based on a preprocessor directive being set/not-set.
[note] I realise I could write both entry point classes in one file and use the preprocessor directive in there, but it's not as neat as a single file calling in one or the other. I figure this should work because I can conditionally include headers for Win/NaCl (providing the signatures match, of course).
I'm making a program to draw a trajectory, was using as a basis the tangent, but when I put 90 degrees, the tangent is very large, so I thought of putting an if (angle == 90) did not use the tangent.
the design is right, but after choosing it 90 degrees it stops to draw.
for example
1-30 degrees - draws 2-45 degrees ---- draws 3 draws -90 degrees --- 4-60 degrees --- not drawing 5 --- 80 degrees --- not drawing * *
I am getting this message from Valgrind, As far as I can see what it points to is initialized. The memory it is referring to is freed in unload and I was not getting this error until after I added the check function. Valgrind was happy. Here is the code and the error message from Valgrind. I am trying to create a spell checker for an assignment for a online class I am taking. I just want to get this table working correctly before I add it to the rest of the program. The code seems to run fine but I have come to see that dos not mean much in C.
arortell@gentoo ~/Development/Projects/C_Projects/Data_Structures/HashTable $ valgrind --leak-check=full --track-origins=yes ./hashTable ==11360== Memcheck, a memory error detector ==11360== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==11360== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info ==11360== Command: ./hashTable
I want to do conditional compilation based on whether it is windows 7 or windows 8. Here is the code below.
#if (_WIN32_WINNT >= 0x0602) //Condition to check whether it windows 7 or 8 .Based on this we can load msxml 3 or 6. #import <msxml6.dll> #else #import <msxml3.dll> #endif
Im building the above code in windows 8 machine.
Issue here is _WIN32_WINNT should have a value 0x0602, it means it is running in windows 8 machine.Instead it has a value 0x0601 (Means it is taking windows version as windows 7 defined in sdkddkver.h).Im not sure after installing windows 8 sdk im not able to see any include or lib files in the path below C:Program Files (x86)Microsoft SDKsWindowsv8.0A . but i can see all include and lib files of sdk version v7.0A available although i did not installed it.
I have airport class which should navigate planes, in its list to runways, with method move, theres a method prepare which changes the direction of flight to all planes, always before move is called, move just increments decrement x and y of plane in its list. But after calling two times in row airport->move(), I get screwed and I really dont know wheres the problem. Have I badly initiazed something? Iterator gets invalidated.
Valgrind Stacktrace Conditional jump or move depends on uninitialised value(s) ==26207== at 0x409601: plane::move() (in /home/xnovak11/Downloads/airport/main) ==26207== by 0x401FBD: airport::move() (in /home/xnovak11/Downloads/airport/main) ==26207== by 0x405FE1: io::start(std::istream&, std:stream&, std:stream&) (in /home/xnovak11/Downloads/airport/main)
This is the method where it fails. When I call it once, no problem, after second call I get instead of normal number in cout<<after move<< s1 i get like 8795456 ....
What happens if I make a server application using tcp protocol and then establish connection with a client application but the server crash and then the client send data. Will the data be lost or the system will continue trying to send it?
This while statement is not cooperating and I am not really sure why. I tried to say while not equal to true and later false, but both produce a never ending loop. I know I posted this before and I got several comments back about different issues with this program. However this question is specific about the while statement.
i am trying to make a ticktacktoe game. I made a simple one with no ai but i decide to add an option to play against computer. And i code like that(i know this is really bad):
I seem to be having a bit of problem with my if statements in a for loop.
My code involves asking the user for the name of an element (chemistry), searching a text file line by line for an element that matches the input, and outputting other information regarding that element.
One line of the text file looks like this: Helium,He,2,4.00
I've tried running the code without the if loop and it outputs normally (If I ask it to output elementname[0] it will output the first element Hydrogen, which is correct.) but I am not sure what goes wrong when I add the if statement. For some reason, it always follows the "else" statement (It always outputs Invalid search even when I input the right elements).
const int ELEMENTS = 118; //number of elements ifstream File; string elementname[ELEMENTS], atomicsymbol[ELEMENTS], atomicnumber[ELEMENTS], atomicmass[ELEMENTS]; string elemname, atomsym, atomnum, atommass; string search;