C++ :: Lines Without Semicolon - Function Calls?
Aug 28, 2013
The below code is taken from open source filezilla project
(FileZilla_3.7.3_srcfilezilla-3.7.3srcinterfacebookmarks_dialog.cpp)
Code:
#include <filezilla.h>
#include "bookmarks_dialog.h"
#include "sitemanager.h"
#include "ipcmutex.h"
#include "themeprovider.h"
#include "xmlfunctions.h"
BEGIN_EVENT_TABLE(CNewBookmarkDialog, wxDialogEx)
EVT_BUTTON(XRCID("wxID_OK"), CNewBookmarkDialog::OnOK)
EVT_BUTTON(XRCID("ID_BROWSE"), CNewBookmarkDialog::OnBrowse)
END_EVENT_TABLE()
I'm unable to understand what are these lines after the #include. They don't end in semicolons. Looks very much like function calls.
Are BEGIN_EVENT_TABLE, EVT_BUTTON and END_EVENT_TABLE function calls? Function calls should end with semicolons right?
View 5 Replies
ADVERTISEMENT
Oct 9, 2014
My function "MatrixMul" returns an int array with multiple values Let's say, res[0] and res[1]
When I'm calling the array in a for loop for multiple times, and when I'm storing the results in another array, in each iteration the results are over-written with the new results.
If the first call returns [0,1] the array will store [0,1] at index [0] and [1], which is fine, but when I'm calling the function again, the new results are stored at the same indexes [0] and [1] How can I avoid that?
The code is:
class Hill_Cipher
{
string AtoZ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public string Hill_Cipher_Enc(string input, int[,] key)
[Code].....
For example, my outPut contains the following: "TH","IS","AT" when I'm calling the function with the first element of array "TH", it converts "T" to its equivalent number and apply some calculations and same with "H". Let's say the final answer is 20 for "T" and 30 for "H". The problem is that every time, encChars will store the values at index 0 and 1: encChars[0]=20 encChars[1]=30 When I call the function again it will store the new values at 0 and 1.... That's because I'm not changing the index value for encChars on each call, so how do I do that?
View 1 Replies
View Related
Nov 12, 2013
So I need to read a file that has this input and need to delete the comma and semicolon in the string but idk how to ignore the comma and semicolon:
ex of input file: A firstname, lastname; 13
I did this:
Code:
i = 0;
fscanf (fData, "%c", &grade);
fgets(space,2,fData);
do{
fgets(name,50,fpData);
i++;
}while(temp[0] == ';');
temp[i] = temp[i - 1];
fscanf (fData, "%d", &age);
View 4 Replies
View Related
Aug 19, 2013
I am trying to write a menu program that will be broken down into a series of calls to function for each of the menu items. Two of the menu items will be simple programs which I wrote.
I want two of the functions to run one of the two programs I am trying to include as items in the menu.
So far I am only familiar with variables, loops, if statements, and I just learned how to write functions.
The problem I am have is that I don't quite understand how to write a function that will run one of the two programs. Also I am having a hard time writing the program in away that would allow the user to select the menu items.
View 2 Replies
View Related
Nov 23, 2014
I am doing a written lab in my programming class in which we must write the output for three lines in a function. However, when I enter the code in my compiler I only get error messages. I was just wondering what the outputs under snap, crackle and pop should be and why.
#include <iostream>
using namespace std;
void snap (int i, int j);
void crackle (int &a, int &B)/>;
void pop (int &e, int f);
int main () {
int i = 1, j = 2;
[Code] .....
View 4 Replies
View Related
Jan 14, 2014
I need to write a code (in C99). The programe receives an input number (integer) 'n' and then a matrix sized n*n (matrix[n][n]), all numbers are integers. We're supposed to define the matrix's size with malloc. Now the program needs to sort the lines of the matrix (the number in each line), in a single function (!) this way:
even line index (0,2,4,6...): from small to big.
odds line index (1,3,5...): from big to small.
and then print it.
*note: first line is indexed 0, second line is 1, etc.
I was thinking to sort it with bubblesort function with the following if:
if(i%2==1)
do odds sorting.
else
do even sorting.
when i is the index of the row.
my problem is defining the malloc and how do I send the matrix to sorting.If needed I will attach my current (not so good (completly awful)) code and functions as well as an example of what the prog. supposed to do.
View 13 Replies
View Related
Jan 10, 2014
I'm doing an exercise that prints all input lines that are longer than 80 characters. I rather not use any libraries so I decided to write my own function that counts characters to use it in my main program. However when integrate things my function returns zero all the time.
Here is my full code:
/* Exercise 1-17 Write a program to print all input lines that are longer than 80 characters */
#include<stdio.h>
/* Declarations*/
#define MAX_STRING_LEN 1000
int count_characters(char S1[]);
int main() {
[Code] .....
So I was trying to debug my count_characters() function and this is the code if I was to run it seperately:
Code:
#include <stdio.h>
/* counts character of a string*/
main() {
int nc = 0;
int c;
for (nc = 0; (c = getchar()) != '
'; ++nc);
printf("Number of characters = %d
", nc);
}
which works...
View 1 Replies
View Related
Jan 6, 2015
I have a multi-thred piece of code that should be fast. As I have to update a Database from time to time, I wonder if I do it in a prpoer manner with calls like this:
Task.Factory.StartNew(()=>update_execution_to_db(exec));
Those are my sporadic updates, my ongoing update have a queue and a dispatcher thread reading from the Q, I just don't want to use this overhead for the sporadic updates.
View 6 Replies
View Related
Mar 7, 2012
Code:
class A {
virtual method1() { };
};
class B : public A {
method1() { }
}
Code:
A* a = new A();
a->method1(); // call B's method1?
Is it possible to call B's method1 in this case?
View 8 Replies
View Related
Apr 27, 2013
This is simple recursive solution of Fibonacci number:
Code:
int fibo(int n)
{
if(n<=1)
return 1;
else
return fibo(n-1)+fibo(n-2);
}
Now the recursion will generate a large recursion tree, like if n=5, 5 will call (5-1), (5-2) or 4,3 . What I want to know is, will fibo(n-1) will be called 1st go all the way to the base case 1, then do the summation or fibo(n-2) will be called right after fibo(n-1) ?
View 6 Replies
View Related
Apr 18, 2014
Let's start with something from the c++ reference:
... delete[] is an operator with a very specific behavior: An expression with the delete[] operator, first calls the appropriate destructors for each element in the array (if these are of a class type) ...
I was wondering if I can tell delete[] to not call destructors, for example if I already know that the delete[] statement should be delete without []. That would be very useful for memory management/memory leak detection.
View 12 Replies
View Related
Feb 13, 2013
I'd like to know what happens if I use multiple calls to malloc() on one pointer (without free) in a single function. Here is the example:
void *data_thread(void *sockfd_ptr) {
int sockfd = *(int *) sockfd_ptr;
const int BUFSIZE = 5;
char recvmessage[BUFSIZE];
char *headerstr = NULL;
char *newheaderstr = NULL;
[code]....
what happens with newheaderstr every time malloc() is called. There isn't a realloc() or anything. I didn't think it looked right to keep using malloc() like that.
View 4 Replies
View Related
Mar 29, 2012
I created a server application but i need to know how to delete my calls to new
Code:
CBaseServer::CBaseServer() {
}
CBaseServer::~CBaseServer() {
}
void CBaseServer::Start() {
struct sockaddr_in ain;
[Code] .....
Also when I call this..
Code:
new CThreadManager();
It gives me this warning...
warning C4345: behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized
View 10 Replies
View Related
Apr 24, 2014
I have several functions doing similar things, inside their implementations, the parameters are the same, but they call different methods.
I want to create one function to make the structure easier, and reduce the duplication. I heard template might be one solution. But I am not sure how to use it in this case.
void GetA(...XXX) {
for()
{
[Code].....
View 1 Replies
View Related
Mar 31, 2014
Code:
scanf("%d", &a);
printf("A");
scanf("%d", &b);
prints "A" after calling scanf two times instead of between the calls (first scan, then print, then scan). I'm using GCC v4.6
View 7 Replies
View Related
Mar 15, 2015
I'm trying to implement a code that recursively calls itself and prints the given digits in ascending order, i.e. if the number is 5, then the function will print 1 2 3 4 5. I cannot use loops in any way!
The problem I have is with keeping my variable i at a set value each time the function calls itself.
void print_ascending(int n){
int i = 1;
if(i < n) {
printf("%d", i);
i++;
print_ascending(n);
}
}
Of course, the problem with this code is it will re-initialize the variable i to 1 every single time and infinitely loop to print 1.
View 11 Replies
View Related
Apr 19, 2013
I need to be able to disable the items on a CCheckListBox but I can't change the code that calls AddString. I know I can use the CCheckListBox::Enable function to disable an item if I have an index but I don't have the index which would be provided by AddString.
I've tried intercepting the LB_ADDSTRING message and then looping through the items in the control but the string has not been added at this point so the last item in the list is never disabled.
I used Spy++ to see what messages were being sent and I noticed that LB_GETTEXT was sent so I tried intercepting this message (ugly hack) but this caused my app to hang - I assume because of the number of times the message is sent. Is there a way to disable the items?
View 10 Replies
View Related
Feb 4, 2013
Well, I have a .txt file that contains, together with a few characters, columns of values that I want to save in different files like is written in the program (file 1, file2, file3 - a with x, b with y, c with z). BUT, I don't want the values from the lines with the saying "interpolated_vector" to be printed in any of the three files.
What I have is the code below, that has the code that creates the three new files with the columns of values that I want. It is working fine!
Code:
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
int i, count;
double *a, *b, *c;
double *x, *y, *z;
char tag[5][255];
[Code]...
I've tried and tried, but couldn't make it work properly. I could only erase one line with "interpolated_vector" using fgets, but all the other lines below this were printed into the three new files (file1, file2, file3).
View 5 Replies
View Related
Nov 8, 2014
I want to write a function called DrawLineSegments.This function must change the color of lines at every corner where the corner angle is greater than 60 deg (Assume that there is a function called checkangle). The color sequence must be black, red, green, blue, and repeat this sequence after the fourth color.
View 1 Replies
View Related
Apr 23, 2013
How I would go about counting lines from a file at the same time as extracting words? I need to know the line number to output what line the word is misspelled on. I tried getline and using sstreams but I could not get it to work.
void SpellCheck::checkValidWords(const string& inFileName) {
string eachword;
ifstream istream;
istream.open( inFileName.c_str() );
if ( !istream.is_open() ) {
[Code] .....
View 3 Replies
View Related
Jul 13, 2013
i want to read text between two indices in the file using file i/o operations in c++. HOw can i do it? for example, here is the text file:
1:
..
..
2:
..
..
3:
..
..
4:
in this text file i need to print only the lines between 2: and 3:. How could this be done?
View 1 Replies
View Related
Oct 21, 2014
I am trying to read lines from a CSV file and put the values into vectors. The CSV contains a large amount of data and I would like the program to only read certain lines from the CSV into the vectors. An example of the data is below. In my code the user inputs a secid. I would then like the code to only read lines from the csv where the secid matches what the user inputs. The secid's are also not in order so I can't just use a while loop.
My current code is below the data.
secideffect_datecusip ticker
10131014MAY19972313510 AMZN
10131008MAY19982313510 AMZN
10131028NOV20002313510 AMZN
10131023JUL20012313510 AMZN
10196601JAN199663858510 NB
10196601OCT199806605F10 BAC
ifstream infile3("filepath.csv");
if (!infile3) {
cerr << "Couldn't open file!"<<endl;
return 1;
[Code] .....
View 1 Replies
View Related
Aug 22, 2014
I want to read certain lines from a file. Let say if the line contains word "makes", the line will be loaded on the screen.how to modify this code.
// reading a text file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
[Code] ....
View 1 Replies
View Related
Dec 27, 2013
I was assigned to modify Game Lobby code. All the data can be saved in txt file and can be displayed when running the code..How can i remove or delete the certain lines of a txt file when running the cmd?.. I cant program it to be able to delete certain lines but i manage to program to delete the entire data, which is not what i want..
Here's the code so far...
#include <iostream>
#include <fstream>
#include<vector>
#include<cstdio>
#include<iomanip>
#include <string>
using namespace std;
class Player {
public:
Player(const string& name = ""): m_Name(name), m_pNext(0) {}
[Code] ....
View 3 Replies
View Related
Sep 15, 2013
I need a way to count lines in a .dat file using fscanf. I must use a regex to check that the characters in the file are alphanumeric. In essence I need to count the ' ' character. I know fscanf ignores this character. I need to exit if it detects anything other than alphanumeric with the digit that is "problem" along with the line number. My .dat file is:
Code:
howard jim dave
joe
(
Maggie My fileCheck.c is: Code: #include "main.h"
int fileCheck(FILE *fp)
{
int ret_val;
int line_count = 0;
char file[BUFF];
[Code]...
The output I am getting is:
Code:
file opened Digit: ( is not an alphanumeric character on line: 5 Program will exit! File closed As you can see, the character "(" is not on the 5th line but the 3rd. It is the 5th "string."
I also wanted to show the regex I am using.
Code:
#define to_find "^[a-zA-Z0-9]+$"
How this can be accomplished?
View 5 Replies
View Related
Mar 19, 2013
I'm having trouble figuring out how to calculate the sum of two lines in the array(for loop)? And the next part, I can return the values to the main program however, how do I do it with c pointers?
(1) Write a C function that takes an integer array argument. The array argument has two rows and NDATA columns where NDATA is a symbolic constant. For each column in the array argument, the function calculates the sum of the values in the first and second row. The function returns to its calling program (using a second argument and call by reference as implemented with C pointers) the maximum of these sums. Additionally the function returns the column subscript where this maximum first occurs. This subscript value is returned the usual way (using a return statement). etc...
Here is the start of the array program
Code:
#include<stdio.h>
#include<stdlib.h>
#define NDATA 5 /* define number of data per row */
int row; /* count rows */
int column; /* count columns */
[Code] ....
View 2 Replies
View Related