Thank you. I don't know why this wasn't splitting string on my end.
It works with below string as well with no comma or ;
char tab[] = "house";
perfect. :)
Type: Posts; User: deathmetal
Thank you. I don't know why this wasn't splitting string on my end.
It works with below string as well with no comma or ;
char tab[] = "house";
perfect. :)
Hi devs,
I am writing a code to parse strings with genetic information. Data are clunky with randomness.
For example,
I need name of each gene separately: GENE1, GENE2 and such. It is...
This is first time I am using getline.
If I code as the following I have to define line char array of a defined length. The column count is fixed in the input file, however, the characters in...
Thank you.
actually I didn't have a new line character in printing that is why poor ptinting.
void remove_trailingspaces(char *newlines)
{
size_t length = strlen(newlines);
...
Thank you for your reply.
I do not have any reason to parse first line (header). The posted data may not have tabs, but the file has. Attached is a small file with first few columns.
My goals are...
Hi there,
Please bear with me. I have a file with multiple columns. I would like split and perform some operations.
When I read file and split using strtok on tab separate it works fine, but I...
No problems.
I will try with #5.
If you get chance can you please review my code I put in my last post?
Thank you laser!
Any code you tried that you could share?
What are these series/numbers based on in each row?
hi laserlight,
the code (trim_whitespace(char *text) with *text = '\0'; in the end ) you shared doesn't work on my end.
Doesn't work mean I don't get the gene name, but complete line.
It could...
Thank you.
I guessed it could be an issue with local and global variable.
Now, I provide another array, copy into it and it works.
#include <stdio.h>
I read in file with four columns skipping line one. File is tab/space delimited, my goal is to get the last column.
I use function where parameter is char array. The function is OK as long it is...
Thank you. I got it.
I would like to store the returned in the result array, so I make changes as below after //
It gets annoyed with an error:
if I make above change I get error as
Thank you laser~!
I have never used strncat. I think the third parameter is for the number of characters to append. That makes me ask
in dest_maxlen - left_len - 1
is -1 at the end for the null character?
...
Thank you laserlight.
I have folowing questions:
1) I cannot understand why dest[0] = '\0'; is needed in the first place.
2) is it OK to mix size_t with C code? As far as I remember C doesn't...
Hi there,
I am new to C from biology background.
I have two char arrays I would like to concatenate. The expected output is two different strings. For example inputs are john and abbey.
The...
Hi Matt,
Thanks for your reply.
unsigned int j=0; ...
Hi,
My goal is to remove extra spaces from line.
I've tried multiple ways, many variables. But I get error for seg fault.
My code:
unsigned int j=0;
Hi laser,
Thanks much for your reply, and explaining in detail.
I'm still trying to absorb what you've said.
I've fixed my code or malloc.
Thank you again.
I can have 2D array as:
1)
char *p[10];
Or,
2)
gcc -v
gcc version 4.9.2 (GCC)
Compiling code:
gcc -g -Wall -Wextra *.c -o program_parse -pedantic -std=gnu99
I've a function which takes in a character array, parses it by tab. And...
Hi,
Thank you for pointing out to the error. Finally it got fixed. Compiler was annoyed with:
p=strtok(line,'\t');
in stead of:
if I include string.h anywhere else and compile, I get warnings as:
Hi laserlight,
Thanks for your reply.
I've
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#define _GNU_SOURCE