Programming :: Read A Blank Line Ie A String Of Length 0?
Apr 19, 2010in gcc how to read a blank line ie a string of length 0.my code:
Code:
#include<stdio.h>
#include<string.h>
[code]...
in gcc how to read a blank line ie a string of length 0.my code:
Code:
#include<stdio.h>
#include<string.h>
[code]...
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]....
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 Relatedbasically 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 RelatedI have an error like this : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''bla..bla..' at line 1. while call my function below:
function InsertSQL(strSQL: AnsiString; CS: TCriticalSection; var ErrMsg: AnsiString): boolean;
var
td: TDBCfg;
SockMySQL: PMySQL;
SQL: PChar;
begin
CS.Acquire;
[Code]...
The function always got this error while length of my strSQL contains more than 256 chars.
I've been trying to understand pthread in C a little better. So I made a simple program that takes in a string from the command line and creates a thread to print the string. I've looked online and copied the basic concepts but there are something things I'm confused about. The programs works just fine, but I have questions. Here's what I have so far.
[Code]....
One thing I'd like to know is why the 3rd argument in the pthread_create function which is my SendMessage function needs to be typecasted to a void pointer and then send the address of the function. Also as for the 4th argument, I would see typecasting to void pointer in some of the pthread examples I saw online, but in my case I'm passing a char pointer, would this be correct? In which case would I ever want to pass a void pointer?
Do I need a pthread_exit(NULL) in my main and in the SendMessage function? If so, why? I added the sleep() function so that I could let the pthread_exit function in my SendMessage function execute first. I simply saw that the online examples on pthread had pthread_exit() in both locations.
I've written a usb device driver and a program that sends and receives data over the bulk pipe. The read function sometimes returnsI'm reading an unknown amount of data. However, using a usb tracker I can see that the correct data is being sent.The error only occurs sometimes.I expect that the read function is told to read more data that it receives it would fail and return -1, however if this was the case then every read call would fail.
View 4 Replies View RelatedI have a set of lines as ahown below:
Leon went to school
Leon came back from school..
Leon had dinner...
I have to replace the line containing "dinner" by a single string LUNCH...
I want to read the line in the text file and get the string in the file and paste it in the directory column
for example i have a line like /ftp/prod/SWC1407.DOC
from this 1407 should be parsed and appended at the end of the move command
mv /ftp/prod/SWC1407.DOC /nfp/1407
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:
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 RelatedI want to read a string into shared memory using shmget and shmat. I'm using something like:
Code:
char *bookmark_strings, *s;
Book_Key = ftok(SHM_LOC,SHM_KEY);
shared_bookmarks = shmget(Book_Key, MAX_BOOKMARKS * sizeof(bookmarks), (0644 | IPC_CREAT));
bookmark_strings = shmat(shared_bookmarks, NULL, 0);
s = bookmark_strings;
*s = "hello";
I know that since it's a string I should be using something other then just char, but with something different shmat fails to be assigned.
I need to read a file and parse a string. I know in Perl there is the split command. Is there something similar to that in C++?
View 6 Replies View RelatedI 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 RelatedI 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]....
Code:
#!/usr/bin/perl
use 5.10.0;
use strict;
use warnings;
use Net::Ping;
[code]....
I need to output of a script to a file with tags.
I'm trying sed and was able to put a tag on the end of the line
Code:
Output is
Quote:
What I need to have is
Quote:
I'm thinking of I redirect my first sed command to a file and then use sed again to put <group> at the beginning of the line. My problem is how to put <group> to all beginning of the string.
I have a requirement like this..this just a sample script...
Code:
when i run this scipt...
Code:
Code:
It is appended in the same line...
I want it to be added to the next line.....
I want to do this by explitly using the filehandles in perl....and not with redirection operators in shell.
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
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.
I want to append a variable string to the end of a specific line. not like append the same string to each line. like in my file i have 4 columns, i want to add a string in 5th column in some fixed row.
View 4 Replies View RelatedQuote:Originally Posted by topcatI would like to know how i can write a shell script to delete a line if a particular pattern exists?E.g. I have a text file with multiple lines. Say 1000s. in the following pattern.
username@email.com:149.0.3.4:1
username1@email.com:149.0.3.4:1
username1@email.net:149.0.3.4:1
username1@email.edu:149.0.3.4:1
If the patternusername@email.com exists then the line "username@email.com:149.0.3.4:1 should be deleted from the file.I have a very similar question but I need to delete one line in a file which matches one very precise instance of a string only. Let's assume I have a file composed of thousands of lines and let's call the file chap-secrets. Let's take the following sample entries:
Code:
#USERNAME SERVER PASSWORD IP
pp pptpd blahblah *
[code]....
I want to know how can I add something to a specific line.. the output would be something like:
abc
def 123
ghi
Search for string "def" and add something to that line.
I think this can be done using sed. Let's say I have file called, "orig.txt" with following contents:
Code:
[User Prefs]
Ignore Unrequested Popups=1
DevTools Splitter Position=500
History View Style=0
[Code]....
So basically if a line contains the word "Home URL" then go ahead and replace that *entire* line with the supplied *new* line.
I have a very large data file, with 3 numbers in each line, ex. 3 4 5 ; 6 7 8.I want to add two numbers (0 and 1) at the end of every line, and a string at the beginning of the line. Does anyone know a efficient way to do so?
View 7 Replies View RelatedInside a loop i'm populating a string variable. Because csh doesn't have very good support for arrays I thought of doing this. I want to add a new line character to the end of the concatenation each time the loop iterates. Then at the end print this variable out.
I tried " and some resources said it was just a "". Neither work. What am I doing wrong?
copy string a to string b and change string b with toupper() and count the chars
View 3 Replies View RelatedHere is the issue. I am reading in a outside text file and putting in the string on that line into a char array that is already allocated.
Code:
int main(int argc, char *argv[])
{
[code]....
I need to search a text file for a string of numbers which are different lengths, and always are between number=" and " like:
number="1234567890"
number="22390"
I need to grab those numbers and pipe each one to a line in a file. I've already tried something with awk and that didn't seem to work.
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