C++ :: Searching For Line Intersections

Jul 26, 2013

I'm pretty decent at maths, and fair at programming but how I'd actually write mathematical line equations or check for intersections in script.

View 5 Replies


ADVERTISEMENT

C/C++ :: Searching Index Files From Linux Command Line

Oct 28, 2014

I have code that creates an index file created from a data file of records.

#include <iostream>
#include <fstream>
#include <map>

[Code]......

View 3 Replies View Related

C :: How Can A Multi-line String Be Read Line By Line

Mar 7, 2014

How can a mulitline string be read line by line

ex: str = "PERIOD="week"
DAY="day"
TIME="time"";

View 2 Replies View Related

C :: ANSI Program To Print Out Each Command Line Argument On Separate Line Using For Loop

Mar 5, 2013

I need to write a ANSI program to print out each command line argument on a separate line using a for-loop. also it need to print the name of the executable .so far I have

Code:

#include <stdio.h>
int main(int argc, char **argv) {
int i;
printf("")

[code]....

View 1 Replies View Related

C :: Program Which Writes Out Its Command Line Arguments In Reverse Order One Per Line?

May 7, 2013

l need to write a program which writes out its command line arguments in reverse order one per line. The output from the program should look like this:

% a.out Two roads diverged in a yellow wood
wood
yellow
a
in
diverged
roads
Two

View 9 Replies View Related

C :: Reading A File Line By Line (invalid Write Of Size X)

Aug 17, 2014

I am trying to read a file line by line and then do something with the informations, so my method looks like this:

Code:
void open_file(char *link) {
FILE *file = fopen(link, "r");
if (file == NULL) {
fprintf(stderr, "Could not open file.
");
exit(EXIT_FAILURE);

[Code] ....

1) The first complain of valgrind is at the line where I use fgets and its telling me (invalid write of size x), but I have allocated my line to 56000 and the read line is shorter, why is there a write size error then :S?

2) at the line where I realloc where I try to shrink the space he's telling me: Address .... is 0 bytes inside a block of size 56000, But I know i need only this space so why is there a write over space error :S??

View 9 Replies View Related

C :: Reading A File Line By Line And Storing It Backwards Into A List

Sep 25, 2013

So I'm reading a file line by line and storing it backwards into a list. So if the file has has this format...
1
2
3
4

The code should store each line in a list as such...
4, 3, 2 ,1

Instead the code will store the last variable in all nodes. So the final list will look like this...
4, 4, 4, 4

Here is my code...

struct node *head = NULL;
int i;
while(read(in, &i, sizeof(int)) != 0) {
struct node *temp = malloc(sizeof(*temp));
temp->line = &i;
temp->next = head;
head = temp;
}

View 4 Replies View Related

C :: Copying File Line By Line Using Dynamic Memory Allocation

Jul 15, 2013

I need to read lines from one file and copy them line by line into another file using dynamic memory allocation. It compiles but gives me a seg fault. Why/How?

Code:
int main(){
FILE *fp1;
FILE *fp2;
FILE *i;
fp1=fopen("file1","r");
fp2=fopen("file3","w+");

[Code] ....

View 2 Replies View Related

C++ :: Comparing End Points Of One Line With The Start Point Of Adjoining Line

Feb 11, 2014

There are numbers of lines connected to each other. I've extracted the line start point and end points but i am confused how to compare the end point of one line with the start point of adjoining line.

View 2 Replies View Related

Visual C++ :: Line Graph Using Single Line Values From Bitmap

Feb 3, 2014

I was loaded a bmp file in my mfc window and stored rgb data in a file.My image size is 320x240.

Is possible to pick a single point (location) from that bmp image (Not the whole window)?

i like to plot a line graph using the pointed single line data using the stored file data?

here R is X Axis and G & B is Y Axis.

If i have 2D array of data means how can i plot the line graph?

View 4 Replies View Related

C :: Fgets To Read A Line Without Returning New Line Char

Nov 5, 2014

I'm using fgets which will read a single line at a time, but unlike fgets I don't want it to return the new line char ( ) ?I want to be able to use printf to display the lines next to each other.

View 7 Replies View Related

C++ :: Read Line By Line From Text File To String

Jul 5, 2013

I have a text file (test.txt) with the following data:

01,05,25,20130728
01,06,25,20130728
01,07,25,20130728
01,08,25,20130728
01,05,25,20130728
01,05,25,20130728
01,05,45,20130728
01,05,65,20130728
01,05,85,20130728
01,05,35,20130728
01,05,25,20130728
01,05,35,20130728

I want to read this to one string called line. So far I have this code:

string line;
ifstream myfile ("/home/Test.txt");
if (myfile.is_open()) {
while (myfile.good()) {
getline (myfile, line);
for (int a = 0; a <= 335; a++) {
cout <<line.at(a);
} }
myfile.close();
}

so far its only printing the first line and then throwing an instance of 'std::out_of_range'

View 2 Replies View Related

C++ :: Read Txt File Line By Line Write To Vector

Oct 5, 2013

I need to read a text file which has various lines containing integers. I need to write those integers separately in a vector. Example, the first line of the text file contains 3 9 8 7 6 so vector[4]=3, vector[3]=9, vector[2]=8 and so on. Next read the second line 4 1 2 3 4 5 and write to another vector vector[5]=4, vector[4]=1...

I tried the code below but it will write from the second line, the whole line in one vector index.

int str; // Temp string to
cout << "Read from a file!" << endl;
ifstream fin("functions.txt"); // Open it up!
string line;
// read line count from file; assuming it's the first line
getline( fin, line );

[Code]...

View 1 Replies View Related

C/C++ :: Reading From A File Line By Line With No Specified Number Of Values

Apr 12, 2015

Im trying to read from a file, line by line, with no specified number of values in the file. Check out my code:

int main() {
string x;
ifstream fin;
int count = 0;
char ch;
fin.open("CWC_Master.txt");
if(!fin)

[Code] .....

Now, this works great! However, its skipping some lines. And I dont know why. For example: Lets say that the input file is:

superman toy
sm2335
19.99
batman toy
bm5532
25.99
aquaman toy
am6786
26.00

Where it should output the above, instead it outputs every other one. Like:

superman toy
19.99
batman toy
25.99
aquaman toy
26.00

How can I fix my code so that it SIMPLY(i say simply because I am still a beginner coder) can read line by line?

View 7 Replies View Related

C/C++ :: Unable To Read Data From Buffer Line By Line

Jun 27, 2014

I'm reading strings one after another and trying to split it using strtok_r. This doesnot seem to be working

I have a .gz file from which I'm reading the data into the buffer in chunks.

The below code works fine only for the first chunk on data. Later it just breaks out.

while(1) {
char buffer[SIZE];
        int bytes_read = gzread (f, buffer, SIZE - 1);

[Code] .....

View 3 Replies View Related

C/C++ :: How To Get Last Line 10 Char In Text File If Last Line Is Null

Aug 24, 2013

I can able to get the last line ten chars but i cant get if the last line is null.

here is my code

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {

[Code] ....

here with i have enclosed my file where i am pick my last ten chars ...

Attached Files : log.txt (4.8 KB)

View 1 Replies View Related

C++ :: String Operation While Reading Line By Line From A File

May 12, 2014

I have to read the information about logic gates from a file. The file format is shown below:

Code:
gateOne = NAND(inpA, inpB)
gate2=NAND(1,2)
3 = NAND(23,25,26)

As, it can be seen from the above structure that whitespaces are not same everytime. So, to deal with this situation, i am using boost library to remove all whitespaces from the line which is being read and then try to find the name of gate and its input. My code is given below which is able to correctly find the gate names and its first input...but my code is not able to find the second, third and so on input names.

Code:
//C
#include <stdio.h>
//C++
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <boost/algorithm/string/erase.hpp>

[Code] ....

View 3 Replies View Related

C++ :: Searching By Last Name?

Oct 23, 2013

I have an assignment to create an address book in c++ where you can enter contact information and then search all entries via last name. I am trouble figuring out how to write a function that will be able to search an entry by last name. Here is my code so far:

#include <iostream>
using namespace::std;
class addBook {

[Code]....

View 1 Replies View Related

C++ :: Searching In CSV File?

Feb 6, 2013

My .csv file is like:

Bone,origin,deep/superficial,location, action.

with list of 38 bones.

This is my main.cpp:

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <cstdlib>
#include "Action.h"
#include "Action.cpp"

[Code] .....

For action, if user enters action, it will output the bones involved with that action.
For strengthening, if user enters location, it will output bones involved with that location.
For dagnostic, if user enters bone, it will output location of bone and whether bone is deep/superficial.

How I could search in csv file for these.

View 11 Replies View Related

C# :: Searching DB For Value In Textbox (WPF)

Nov 3, 2014

WPF window I'm working on. I have a window that has a textbox to enter a name to search a database table for, and when the search button is clicked, the ID for that username will be returned to a separate textbox. The code I've written atm doesn't seem to be working, but it looks fine to me. Here's what I've got;

private void btn_SearchUsers_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrWhiteSpace(txtb_SearchName.Text))
{
SqlConnection sqlCon = new SqlConnection(conStr);

[Code] .....

So, I have the value entered into the textbox to be searched for stored in a variable, I'm selecting the ID from the table when the name in the variable is found, storing the result in a DataTable, and then in my foreach loop, if I find the name (the name column being index 1 in the table), I set set the ID result textbox to equal the ID for that name (the ID column being index 0 in the table). I think the foreach part is what's throwing me off. Maybe the column stuff? My Users table is like;

ID Name
1 John
2 Roger
3 Mike

View 3 Replies View Related

C :: Reading File Line By Line On Windows?

Oct 13, 2014

How to read a file line by line and then later access them by doing something like

Code:
lines[0] //Line number one
...
lines[100] //Line number one hundred and one
lines[100][0] //L
lines[100][1] //i
lines[100][2] //n
lines[100][3] //e
lines[100][4] //
lines[100][5] //n
...

View 13 Replies View Related

C :: How To Print Strings On The Same Line Without Moving To Next Line

Mar 12, 2013

Just working up for the google coding contest to start soon and have been practising some of the test questions however i make correct algorithms but my output is rejected because of the fact that my strings are printed on a new line so i wish to know a method to print strings using a printf statement or any other function on the same line ...

View 3 Replies View Related

C++ :: Get Last Line Displayed By Another Command Line Window

Apr 14, 2013

I write a program which now works perfectly well. However, I want to make it run at the right time automatically, instead of waiting for a user to start it when needed.

The basic problem is, that in a WinPE environment an exe is running. Unfortunately it would need critical input, which must be inputted perfectly. So, I wrote a program which gets the data and sends it to the other app, by bringing it to the front and presses the keys needed using SendInput().

However, this program should wait for it's cue, then get on the inputting part. It's cue should be the point where the program waits for the first user input with this displayed on the last line:

Text:

My question is: how to listen and check whether the last line displayed is "Text:"?

I've tried with AttachConsole(), but for some reason it opens a new console window. I checked and the PID I'm using is the console window's, so I don't know why that happens.

The few lines I'm trying with:

HWND hwnd = FindWindow(NULL, "Administrator: Command Prompt");
SetForegroundWindow(hwnd);
SetFocus(hwnd);
DWORD process_id;
GetWindowThreadProcessId(hwnd, &process_id);

[Code] ...

Please don't criticize the first line. I know it can be ambiguous, but I modified it, When actually using it, the exe name will be in the title, so it will be unique.

View 4 Replies View Related

C++ :: How To Read Data From A File Line By Line

Jul 2, 2013

I have an external file with one column of data. If I have a counter value let say counter =1, and counter++ and so on. How I can write such a c++ code that if the value of counter and value from the external file are same then generate an action let say cout both values i.e. value of counter and value from external file.

for more information, here is an example:

data in file(in one column): 2 6 8 9 10...
value of counter : 1 2 3 4 5 6 7 8 9...

then cout values only if value of counter and value from the file is same.

Here is my code so far, but it does not seem to work;

#include<iostream>
#include<fstream>
using namespace std;
int main() {
const int SIZE = 10; //Size declaration of array
int hours[SIZE]; //Array declaration

[Code]...

View 12 Replies View Related

C++ :: Read File Content Line By Line

Jan 23, 2015

I am reading my file (20GB) line by line using boost like this

PHP Code:

boost::interprocess::file_mapping* fm = new boost::interprocess::file_mapping("E:Mountain.7z", boost::interprocess::read_only);
boost::interprocess::mapped_region* mr = new boost::interprocess::mapped_region(*fm, boost::interprocess::read_only);

 char* bytes = static_cast<char*>(mr->get_address()); 

An exception is thrown in the second line while allocating memory for mr.

I use boost because it can also work in Mac which my code will be ported to.

View 3 Replies View Related

C :: Searching Word Using Strcmp

Nov 15, 2014

I'm trying to write function that finds wheter the searched word exists or not. The compiler gives warning. Where is my wrong ?

|21|warning: passing argument 1 of 'strcmp' makes pointer from integer without a cast [enabled by default]|

Code:

#include <stdio.h>
#include <string.h>
int main ()
{
int result;
char arr[]="sakir emmim evde mi evde mi dedik lan";
int size=sizeof(arr)/sizeof(char);
char key[20];
scanf("%s", &key);

[Code]...

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved