Programming :: Read The Presence Of A Blank Line In Gcc?

Apr 20, 2010

in gcc how to read a blank line ie a string of length 0.

my code: Code:
#include<stdio.h>
#include<string.h>
#include<string>
using namespace std;
[Code]....

View 4 Replies


ADVERTISEMENT

Programming :: Read A Blank Line Ie A String Of Length 0?

Apr 19, 2010

in gcc how to read a blank line ie a string of length 0.my code:

Code:
#include<stdio.h>
#include<string.h>

[code]...

View 3 Replies View Related

Programming :: Create A Simple Program With Will Continually Read Input From The User Until They Enter A Blank Line?

Apr 6, 2011

basically i have to create a simple program with will continually read input from the user until they enter a blank linei know how to read in certain input but not sure how to get it continually in a loop

View 2 Replies View Related

Programming :: Open Two Text Files - Read Them Line By Line And Update Parameters Of The 3rd File ?

Oct 18, 2010

I have two txt files containing x and y coordinates: xcoord.txt & ycoord.txt. I need to open them; read them line by line to get each coordinate; then each time I need to update Xs and Ys parameters inside another file called "dc.in" with the grabbed values.

Finally each time I need to run two exe files ( dc_2002 and st_vac) and produce corresponding output for each Xs and Ys ( dc.in is an input file for this exe files)

I have written the following code but it does not work:

View 14 Replies View Related

Programming :: Bash: Read A Text File Line By Line?

Jul 7, 2011

bash 3.1.17(2) I'm trying do write a shell script which must operate on each line of an ASCII text file. So, all the code must be inside a loop, and inside the loop, the first thing should be to read the next line from the file. I have the bash read command. But it reads from stdin. Any way to make read from a file?

View 6 Replies View Related

Programming :: Perl Script To Read Line By Line

Aug 2, 2011

I just learn perl script.May i know how to simplify the code below especially in the red color part? i saw some examples in internet, they use "next" command.

View 20 Replies View Related

Programming :: QTimer To Read A File Line After Line?

Mar 25, 2010

I need a qtimer to trigger reading of a file line by line, I have the code sort of running with the timer trigger but qtimer will just read the first line over and over as it is now.

Here is the code so far:

self.lcdtimer = QTimer()
self.connect(self.pushButton85,SIGNAL("clicked()"),self.update)
self.connect(self.lcdtimer, SIGNAL("timeout()"), self.lcdxyz)

Code:

def lcdxyz(self):
import time
import os

[code]....

View 12 Replies View Related

Programming :: Read In Stdin And Ping Line By Line?

Jan 8, 2010

Code:

#!/usr/bin/perl
use 5.10.0;
use strict;
use warnings;
use Net::Ping;

[code]....

View 1 Replies View Related

Programming :: How To Read Line By Line In A File In C

Feb 5, 2010

i want to read line by line in a files in C language actually my porblem is i have a one file cotains

if iam using fgets, it is reading each time AT only it does not moving to Ok in that file

View 6 Replies View Related

Programming :: Read File Line By Line?

Mar 23, 2011

so I have a script that creates couple of txt files. First file output is something like below..

cn=test,ou=something,ou=some,o=org
cn=testa,ou=something,ou=some,o=org
cn=testb,ou=something,ou=some,o=org

second file output is something like below..
usera
userb
userc

Quote:

userdn=`ldapsearch -x -h $server -LLL "(objectclass=person)" dn | grep dn: | cut -d" " -f2 > userdn.txt

for i in $(cat userdn.txt);do

ldapsearch -h $server -p 389 -x -D $admid -w $admpwd -s one -b "$userdn" dn | grep dn: | cut -d" " -f2 | cut -d"=" -f2 | cut -d"," -f1 > user.txt

for i $(cat user.txt);do

echo "$userdn"
done
done

when I ran both ldapsearch commands invidually, they work fine. But when I ran script, I got first file correctly but not the second one. It looks like its not reading the first file correctly and not setting the variable ($userdn) value correctly in the second ldapseach command. I want read first file first line and run the second ldapsearch and continues, then read the second line..and so on.

View 3 Replies View Related

Programming :: Read A Line From A Txt File In A Script?

Dec 9, 2010

have been playing around with a script for a few hours and now I need to be able to output the lines in a text file one by one to be used later in the script.What it gonna do is to read a log file and grep the usernames, then write them to a file, and then run one script for each user, to search for more information about them in the log.But I don't know how to output a single line from a file, and google does not return any solution.

View 3 Replies View Related

Programming :: Read In A File 1 Line At A Time?

Oct 22, 2010

i am trying to read in a file 1 line at a time and for some reason it stops printing out at about line 62,000.

i am doing this:
Code:
while(fgets(c0, 1085, fstream0) != NULL)

but after about 62,0000 lines it stops printing. no seg-fault, no core dump. it just stops printing to the terminal then returns me to the command line after a couple of minutes. as a hack i am doing split -l 50000 on the input and calling my program 5 times.is there some limitation on fgets that i am not understanding ?

View 8 Replies View Related

Programming :: Read Each Line Of A File As Input?

Jun 21, 2011

I'm writing a program which now accepts user input:

Code:
echo "Enter a date in the format YYYY MM DD hh mm ss."

read gregyr gregmo gregdy greghr gregmn gregsc This lets the user input a date and time, such as 2011 06 21 15 12 45, and have each number assigned to their corresponding variable. Later in the program, these variables are put into an equation, and then the terminal spits out the answer. Now I have to have the program read all of the lines from a text file, which is in this format, assign the variables.

View 7 Replies View Related

Programming :: Read A File That Counts Each Line And Numbers

May 13, 2010

I ran into it while google Segmentation Fault. I'm writing a simple C program that reads a file that counts each line and numbers it then writes to a file called sdout. I copyed my program mostly from the text book but im still having problems. Heres my code:

#include <stdio.h>
#include <stdlib.h>
void new_line(FILE *, FILE *);
int main(char *argv)

[Code]....

View 14 Replies View Related

Programming :: Looping Using While Read Line And A Variable Instead Of A File?

Sep 24, 2010

I created the following.

x="top
middle
bottom"

I would like to make the following work.

while read line
do
echo $line
done

instead of importing a file I would like to use the variable $x I tried using pipes, but with no luck. My goal is to read one line at a time, but not have to export my data to another file, I would like to keep it all within one script.

View 3 Replies View Related

Programming :: While Read Line - Doesn't Work With Ssh In The Loop Body

Mar 26, 2010

I am trying to read the names of hosts from a file and do a ssh to see if processes are all running or not.

Here is the outer loop that is causing problem:

hosts.lst is a text file that has the host names in each line.

The problem is that the loop just breaks after the first run. Somehow while read line becomes invalid when the body of the loop does the ssh and returns.

View 5 Replies View Related

Programming :: Bash Shell Read User Argument From Command Line And Test It

Aug 29, 2010

Trying to create a small script that will read user's input, test if user entered some input and if not display some message or display a text using user's input.

The script is the following but i get an error saying "[: 6: =: argument expected"

View 12 Replies View Related

Programming :: Sed Terminated Prematurely By Presence Of C In Input

Jun 17, 2011

Sed seems to react to the presence of "" in its input if the immediately following character makes the pair a recognizable code. In the code following see that the "a" and "" are missing in the output, and that the "c" caused sed to terminate at that point. Is there any way to prevent it reacting like this?

Code:
g y="the shell built-in command. The following character sequences
> have special meaning:
> a Alert (bell).
>  Backspace.
>
> c Suppress trailing newline.
> f Form feed.
>
[Code]....

View 3 Replies View Related

Programming :: Check The Presence Of USB Using /proc Interface In A C Program

Feb 22, 2010

I want to check whether a USB is plugged in its slot from a C program. I want to make use of /proc interface for the same. During my reading i found that /proc/bus/usb/devices will tell how many USB devices are currently present.

So whether i can open this file and use stat call to identify whether the size is 0. If size is 0, i can assume no USB present. Else i can assume USB is present.

Whether my understanding correct. If USB inserted, how can i check the folders present in the USB stick.

View 2 Replies View Related

Programming :: Write Script To Look For The Presence Of Memory Allocation Calls Without Corresponding?

May 14, 2011

I need to write script to look for the presence of memory allocation calls without corresponding calls to free the memory

View 5 Replies View Related

General :: Parse A File And Print Each Line That Ends With Matching Pattern (if The Next Line Is Blank)

Aug 2, 2010

I've written a script to parse a file and print each line that ends with matching pattern, if the next line is blank. The pattern lines are the result of md5sum $i|sed 's/path///g' so that only md5 and filename appear. Here's what I'm using.

Quote:
for fline in `sed -n '/.*.ext$/p' file1`
do
if [ "`sed -n -e '/'"$fline"'/ {n; p;}' file1`" == "" ]
then
echo ""$fline" has no info" >>file2
fi
done
[Code]....

View 4 Replies View Related

General :: Script Which Read Line By Line /passwd Using While?

May 13, 2010

I have to do several scripts and I have no idea of how to do this one: Make a script that read line by line the passwd file and prints in console.Hope you understand couse my english isso bad as you can see.Our teacher told us something like this:#!/bin/bashwhile read line doecho $lineadone < dispositiveexit

View 9 Replies View Related

Software :: How To Read Line By Line In A File In C

Feb 5, 2010

i want to read line by line in a files in C language actually my porblem is i have a one file cotains

AT
OK

if iam using fgets, it is reading each time AT only it does not moving to Ok in that file

View 3 Replies View Related

Programming :: Copy And Replacing Specific Line From File1 To File2 Line By Line

Mar 22, 2011

I have two files, file1.traj and file2.traj. Both these files contain identical data and the data are arranged in same format in them. The first line of both files is a comment.

At line 7843 of both files there is a cartesian coordinate X, Y and Z ( three digits ). And at line 15685 there is another three digits. The number of lines in between two cartesian coordinates are 7841. And there are few hundreds of thousands of lines in a file.

What I need to do is copy the X Y Z coordinate (three digits) from file1.traj at line 7843 and paste into file2.traj at the same line number as in file1.traj. The next line will be 15685 from file1.traj and replace at line 15685 at file2.traj. And I dont want other lines (data) in file2.traj get altered. This sequence shall be going on until the end of the file. Means copy and substitude the selected lines from file1.traj into file2.traj.

I tried to use paste command but I cant do for specified line alone.

Here i showed the data format in the file. I used the line number for clarity purpose.

Code:

View 10 Replies View Related

Programming :: Access A File Line By Line, And Check The Length Of Each Line.

Feb 13, 2011

I want to access a file, and check the length of every line.After, i want to check and replace all lines with length over 10 characters, with a message.Does anyone have a clue on that?

View 1 Replies View Related

Programming :: Compare Two Files Line By Line And Print The Line Which Is Same?

May 30, 2011

I am trying to write a program in C which compares two files and prints the line that is equal.

Here file1.txt has

and file2.txt has

Note: file2.txt consist of only a single string where as file2.txt has multiple lines. Actually im comparing two files with md5sum values.

Here is the code but it compares only first line of files..but it should compare the whole file1..and sorry iam a beginner in C can any1 sujest some modification to this code so that..it can compare file2 with entire file1

Quote:

View 9 Replies View Related

Programming :: Insert Line Using Sed Or Awk At Line Using Line Number As Variable

Jul 25, 2011

I want to insert a line at a particular line number using sed or awk. where line number is not fixed and is in form of variable.

I want to use variable in sed or awk command.I tried something like below, but no luck.

View 7 Replies View Related

Ubuntu :: Blank CDs Read With 0 Bytes Memory?

Jan 14, 2010

Every single blank CD i put into my computer show it has 0 bytes of memory and i cannot write things onto them. I dual boot 9.10 and Windows XP, and Windows reads them just fine. Ubuntu will mount the disk as "Blank CD-R Disc, i can access it, and everything works except when i look at the properties it says there are 0 bytes used and 0 bytes free. The drive reads discs with data on them just fine, and they work flawlessly, its just blank discs that dont work. What i need to know is if there some property i need to change or a line i need to put in the terminal to make it read blank discs? Or am i completely screwed?

View 5 Replies View Related

Programming :: Create File Listing In C++ That Will Generate Line Number On Every Line Of Code

Apr 11, 2010

I have a project due for my Intro to C++ class and we are suppose to generate a file listing that will take an input of a C++ source code with .cpp extension and make a copy of it with a .lst extention that will have a line number preceding each and every line.

View 12 Replies View Related

Programming :: Set Indent In .emacs To Enable New Line Starts From The Same Position Of Previous Line?

Dec 29, 2010

How can I set indent in .emacs to enable my new line starts from the same position of previous line?

like this;

Hello world <enter>
Second Hello world // "S" starts right under first line's "H"

View 4 Replies View Related







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