I'm trying to add insert functionality to a textbook code example. I have an "off by one" error and I can't think of a way to fix it. Here's my attempt below: template< class NODETYPE > void List< NODETYPE >::insertMiddle( const NODETYPE &value, int position ) { ListNode< NODETYPE > *newPtr = getNewNode( value ); ListNode< NODETYPE > *curr = firstPtr; ListNode< NODETYPE > *curr2 = firstPtr; if ( isEmpty() ) firstPtr = lastPtr = newPtr; else { if (position == 1) insertAtFront( value ); cout << "curr->data is: "<<curr->data<<endl; for (int i = 1; i != position; ++i) curr …

Member Avatar
Member Avatar
+0 forum 3

Hello! I am interested in the issue of protecting the code from hacking. Do you protect your code from decompiling and hacking? Why did the question arise? I worked in a team that developed games for Android. They all used obfuscators! So almost no one could hack their application. Now I am interested in the topic of code protection. I looked at the existing topics, they are slightly outdated (8-10 years ago were relevant). Use / not use obfuscator? Which to choose?

Member Avatar
Member Avatar
+1 forum 15

i create the read(...) function for read to variables. but i need too the read()(without arguments) for press enter before continue\exit. void read() { //wait if the enter key is pressed: cin.ignore(); cin.get(); } template<typename first_t, typename... rest_t> void read(first_t &first, rest_t... rest) { std::cin >> first; read(rest...); //function is recursive //when the parameter pack becomes empty //read(); will be called with no parameters //which is why we declare it above } void read(string &parameter) { std::getline (std::cin,parameter); } void read(char *parameter) { cin.getline (parameter, 256); } read(); the problem is that i need press, 2 times, the enter for …

Member Avatar
Member Avatar
+0 forum 11

i'm trying using the GNU compiler with command lines( using the ShellExecuteEx()). when i do: string FileName1="C:\\Program Files\\mingw-w64\\x86_64-7.2.0-win32-seh-rt_v5-rev1\\mingw64\\bin\\x86_64-w64-mingw32-g++.exe"; run(FileName1,"-c \"C:\\Users\\Cambalinho\\Documents\\CB\\testfolder\\bin\\Debug\\test2.cpp\""); the object file is created. these line creates the exe: run(FileName1,"-o C:\\Users\\Cambalinho\\Documents\\CB\\testfolder\\bin\\Debug\\test2.exe C:\\Users\\Cambalinho\\Documents\\CB\\testfolder\\bin\\Debug\\test2.o"); (tested) but the exe have some dependencies... so seen the Code Blocks: x86_64-w64-mingw32-g++.exe -Wall -g -std=c++14 -c C:\Users\Cambalinho\Documents\CB\testfolder\main.cpp -o obj\Debug\main.o x86_64-w64-mingw32-g++.exe -L"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86" -o bin\Debug\testfolder.exe obj\Debug\main.o -static-libstdc++ -static-libgcc -fpermissive "..\..\..\..\..\Program Files\mingw-w64\x86_64-7.2.0-win32-seh-rt_v5-rev1\mingw64\x86_64-w64-mingw32\lib\libgdi32.a" Output file is bin\Debug\testfolder.exe with size 2.92 MB Process terminated with status 0 (0 minute(s), 8 second(s)) 0 error(s), 0 warning(s) (0 minute(s), 8 second(s)) the "-static-libstdc++ -static-libgcc" adds the exe …

Member Avatar
Member Avatar
+0 forum 7

Hi all, I'm having a little problem with array and some "unqualified-id" problem. I've created gazillions (okay, maybe 80) arrays before but I had never encountered such problem. Especially with static arrays. [CODE] #include <stdio.h> #include <cstdlib> using namespace std; int main() { // with addition of buffers for 3x3 square mask // 8x8 original image is now 10x10 int [][] imageSquare = //12 { {4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4,48, 4, 4, 4, 4, 4}, {4, 4, 4,64,64,64,64, 4, 4, 4}, …

Member Avatar
Member Avatar
+0 forum 10

This is a tutorial, not a program. [b]Step 1[/B] First, create a file for your website, and name it "admin.html". [b]Step 2[/b] Now on it, say, "You must log in to view admin, blah,blah,blah. Click here to launch our client." [b]Step 3[/b] Link "Click here" with the C++ .exe file we will create later. [b]Step 4[/b] Now, create a new file with a bunch of random letters, then ".html". Make the file name AT LEAST 100 characters long. All your admin stuff will go here. [b]Step 5[/b] Now Start a C++ program, and type the following: [code=c] #include <iostream> #include …

Member Avatar
Member Avatar
-5 forum 10

#include<stdio.h> #include<conio.h> typedef struct process{ char pname[20]; int at,bt,wt,ta,end; }processes; int main(){ processes P[10]; processes z[10]; processes et[10]; processes wt1[10]; processes ta1[10]; int a,b,n,x=0,st,y,w; float aveta,avewt,sumta=0,sumwt=0; printf("Process Scheduling Algorithm:\n"); printf("SHORTEST JOB FIRST\n"); printf("--------------------------------------\n"); printf("Enter No. of Process: "); scanf("%d",&n); printf("\n"); for(a=0;a<n;a++){ printf("Enter Process Name P[%d]: ",a+1); scanf("%s",&P[a].pname); } printf("\n"); for(a=0;a<n;a++){ printf("Enter Arrival Time for P[%d]: ",a+1); scanf("%d",&P[a].at); } for(a=0; a<n; a++) { if(st > P[a].at) { st = P[a].at; } } printf("\n"); for(a=0;a<n;a++){ printf("Enter Burst Time for P[%d]: ",a+1); scanf("%d",&P[a].bt); } printf("\n\n ========================================================================\n"); printf("||\tPROCESS \t||\t ARRIVAL TIME \t||\t BURST TIME \t||\n"); printf("||----------------------------------------------------------------------||\n"); for(a=0;a<n;a++){ printf("||\t P[%s] \t\t||\t %d \t\t||\t %d \t\t||\n",P[a].pname,P[a].at,P[a].bt); …

Member Avatar
Member Avatar
+0 forum 4

hello there. i needed a little help in writing coding for reading multiple lines of data from a .txt file that are seperated by commas. Student Name, Student ID, Mark Ada Lovelace , S001 , 99 Barbara Liskov , S0123 , 44 Carol Shaw, S0023 , 55 Donna Dubinsky , S8333 , 33 Shafi Goldwasser , S934 , 77 Sophie Wilson , S11813 , 22 Frances Elizabeth Allen , S8254 , 66 After reading the data, the data has to be graded and sorted by name, id and grade. i would very much appreciate your guys help in this

Member Avatar
Member Avatar
+0 forum 7

Well, right now i'm following a tutorial on game making for c++, but is this really the best programming language for video games? Also i'd like to know if can recommend me a book ( i've seen some book on amazon but i don't really know wich one to choose ), or tutorial about this, cause since i'm just 15, there's no teacher ( yet ) to talk with about this kind of things ( Consider that i'm a really noob sooo... ) Well thanks and thats all

Member Avatar
Member Avatar
+0 forum 38

i have 2 sperate projects which i am trying to run together as a shared project but i am failing hard……. Basically, first project does infix to postfix notation and the second projects does postfix evaluation. tried to run all that in 1 project but i keep getting all sorts of error and cannot figure it out, I am kind of lost don’t know what to do. any suggestions would be really appreciated!!!!!!!!! the first 3 files is infix to postfix project and the last one is posftix evaluation. this is the calculator.cpp #include "stdafx.h" #include "Calculator.h" #include <iostream> #include …

Member Avatar
Member Avatar
+0 forum 6

Hello, I am building a calculator in c++ windows application form, i want the calculator to handle multiple operator precedence (for example, 2+4*5/3). but i am not sure how to write the following code on my windows form project. Any suggestions would appreciated . #include <iostream> #include <conio.h> using namespace std; int main() { int num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0; char op1, op2, op3, op4; int total1 = 0, total2 = 0, total3 = 0, total4 = 0; cout << "Enter five values with operator to calculate=>"; cin >> num1 …

Member Avatar
Member Avatar
+0 forum 6

in working with my 2d arrays, i have to read in from an input file a char array of NxN and manipulate the matrix in various ways. i have gotten just about everything finished, except i cannot figure out the logic of shifting a row left or right, or shifting a column up or down. i know i have to temporarily store the last element in a row or column, and then i get stuck on figuring out moving an element from there. i have this for trying to shift a row right that the user specifies. this part here …

Member Avatar
Member Avatar
+0 forum 8

I’m new to this and talking an intro class. I’ve read and reread my course material so far and I can’t get this line to work. It has to display You have 2 even and 3 odd numbers but no matter what I do, it keeps coming out with 0 even and 0 odd. Tried used if (number %2==0){ number = even} If(number %2!=0){ number = odd} but that’s not working. Any suggestions

Member Avatar
Member Avatar
+0 forum 4

hello coders, i hope you all are going well, one thing blows my mind today in c i can't explain it this is why title is akward, so the thing is i have an array called tab[n] i wanted to invert it elements from tab[0] to tab[n-1] and and the tab[midle] would remain the same so i used intermediate variable x, max, half, what i get in resutl is just unexpected because before the entering the loop for the value of max is equal to 14 once once in the for loop max is equal to 0 i don't understand …

Member Avatar
Member Avatar
+0 forum 5

Good Evening, I'm working on my final project and I'm having an issue with reading input from a file and converting the string into an integer - specifically with the first character being read from the file. Here is the data in the .txt file created in notepad: 6 -1 -1 -1 2 -1 -1 -1 9 -1 1 -1 3 -1 7 -1 5 -1 -1 -1 3 -1 -1 -1 1 -1 -1 -1 9 -1 -1 -1 -1 -1 2 -1 2 -1 -1 8 7 5 -1 -1 3 -1 -1 5 -1 1 -1 4 …

Member Avatar
Member Avatar
+0 forum 1

write c++ programming that calculate electricity bill with persons name and id

Member Avatar
Member Avatar
-1 forum 5

Hi all, So before I went and posted ~800 lines of code, I have 2 questions: 1: What is the preferred way for us to post "complex" C++ (of course, this is just a .h, .cpp, and main cpp but it's still a lot of lines) that wont just be obnoxious to read/debug? (I guess.. what is the proper etiquette here?) 2: Maybe I don't have to post it, and I can get theory help - I have a socket server that spawns threads with mutexes to control everything as needed (I think I am doing it right). When I …

Member Avatar
Member Avatar
+0 forum 7

Is it possible to know which connection sent data wiht recv()? Current setup is - Main Thread spins and waits - Thread 1 - do stuff unimportant to socket - Thread 2 - accept() -> keep linked list of accetpted sockets - Thread 3 - recv() -> can I know which IP addr/connection sent me the data I am currently reading? Thank you :) Ryan

Member Avatar
Member Avatar
+0 forum 1

I bought new esp8266 WiFi module ....if I run example program blink its working but if I upload Wi-Fi http client program I am getting some strange output in serial monitor like ???!°^∆ I thing some encoding problem pls help me out

Member Avatar
Member Avatar
+0 forum 3

Inside of a class template having parameter `typename T` the compiler generates an error concerning 2 functions. `T` does not seem to be recongnized as the template class parameter it was declared as. template <class Return, class ...Args> void executeOnAll(Return (T::*function) (Args &&...), Args &&...args) { for(T &s : *this) (s.*function) (std::forward<Args>(args)...); } template <class Return, class ...Args> void executeOnAll(Return (T::*function) (Args &&...) const, Args &&...args) const { for(const T &s : *this) (s.*function) (std::forward<Args>(args)...); } As my array class has many other member functions, this error is specific to the 2 above. Error Output: c:\appprojects\js3d\source\jscommon\msvc\../jarray.h(244) : error C2825: 'T': …

Member Avatar
Member Avatar
+0 forum 2

Hello all, i need your help regaring this code, which is in python and i need to convert it into mips?? register $s0 holds the base address of list my_data, $s1 holds the length of the list my_data, register $s2 holds the base address of list my_data2 and $s3 holds the length of the list my_data2. def sum_to_x(x): sum = 0 for i in range (x): sum += i return sum my_data = [1, 3, 6, 7] my_data2 = [2, 1, 5] for i in range( len( my_data ) ): my_data[ i ] = sum_to_x( my_data[ i ] ) for …

Member Avatar
Member Avatar
-1 forum 6

Hello, Please, i dont know why my implementation is failing the testDemo Fucntion.. Below is the full code. it is Failing operator < .... testLessThan interface: #ifndef DATE_H_ #define DATE_H_ #include<iostream> using namespace std; class Date; ostream &operator<<(ostream&, const Date&); istream &operator>>(istream&, Date&); class Date { private: int month; int day; int year; int hour; int minute; int second; public: virtual ~Date(); Date(void); Date (int month, int day, int year, int hour, int minute, int second); virtual void setMonth(int&); virtual void setDay(int&); virtual void setYear(int&); virtual void setHour(int&); virtual void setMinute(int&); virtual void setSecond(int&); virtual int getMonth(void) const; virtual int …

Member Avatar
Member Avatar
+0 forum 3

I need to convert hours into weeks, days, and hours. My professor was hinting that there might be a way to do this using the modulus operator but I can't seem to think of a way that its possible. Can anyone help? thanks!

Member Avatar
Member Avatar
+0 forum 9

I'm having a problem with the program i did. The problem is ; It says that the conversion ( for the grade part , the ones with '+' and '-') may lose it's significant digit.. Does it mean that i can't use the plus symbol or the minus symbol ?? or i need to declare how many characters for *grade* ? ( char grade [5] ? ) How many nested if's can i do? And another one is , it says i misplaced the last else .. Um , does it mean that the *else if* above it needs a …

Member Avatar
Member Avatar
+0 forum 4

#include<iostream.h> void main() { int a,b,r; cout<<"a=";cin>>a; cout<<"b=";cin>>b; while (r!=0) { r=a%b; a=b; b=r;} cout<<"cmmdc="<<a;

Member Avatar
Member Avatar
-1 forum 2

Hello, Please I want to get an input of string, like mm/dd/yyyy hh/mm/ss where first mm is month,.... and second mm is minutes.... then want to split each into date object.. like ... month day year.... after each / .... I am lost here... thanks istream &operator>>(istream& inputStream, Date& dateObject) { string inVariable[20]; inputStream.getline(inVariable, 20, "\n" ); //inputStream >> inVariable; }

Member Avatar
Member Avatar
+0 forum 3

I am trying to learn error trapping using the C++ commands try, throw, and catch. The problem I seem to be encountering is when I use new to declare an array. When the program throws an exception, don't I need to delete those arrays to prevent a memory leak? I am thinking yes. But, when I try to compile code with the delete commands in the catch, I get a variable out of scope error from the compiler. I am doing something like this: int function () { try { string * files = new string[dirsize]; code; if (something bad …

Member Avatar
Member Avatar
+0 forum 3

Hi Guys. I'm not a c++ dev but a VB.NET developer. I will first explain my scenario so that the question would be clear. Suppose I had a form which has a Label contro named label1 and the project name is Test which is done in a Visual Studio using the CLR template. **Files** > I will just mention files which are related to the question only. 1) Form1.h 2) Test.cpp Now I have functions (Tasks which the application should perform) on Test.cpp. My question is how do I update a label1 control within Test.cpp file inside the function. Sample …

Member Avatar
Member Avatar
+0 forum 8

Hi DW. Is there anyone know how to read a text file line by line from the web/internet in VC++? I have a function which works well in reading the local file but its seems as if its doesn't find or read a file on a web server. A file I would like to read is located on a web address like this : http://www.thesitedomain.com/test.txt Any working idea in solving this problem?

Member Avatar
Member Avatar
+0 forum 8

I'm writing a code that will save the username of a user when a button (in this case button1) gets pressed. I save it to a file called info.txt, and i use fstream in order to save it. Currently I'm running into the issue that, while i can open up the file fine, I can't save the data from textBox1 because it uses the data type String ^, while fstream doesn't support writing in that type. Here is my relevant code: private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { std::ofstream settings("settings.txt"); settings >> …

Member Avatar
Member Avatar
+0 forum 2

The End.