split « string « C File Q&A

Home
C File Q&A
1.array
2.binary
3.delete
4.Development
5.directory
6.fgets
7.fopen
8.fprintf
9.fscanf
10.fwrite
11.header
12.include
13.input
14.LINE
15.linux
16.open
17.output
18.pointer
19.read
20.size
21.string
22.struct
23.Text
24.windows
25.write
C File Q&A » string » split 

1. splitting a full filename into parts    stackoverflow.com

I am creating a function that will split a full unix filename(like /home/earlz/test.bin) into its individual parts. I have got a function, and it works for the first two parts perfect, ...

2. Split string in sequential file to add a tabstop between the strings...    cboard.cprogramming.com

#include #include #include #define N 100 int main() { FILE *fP; char str[N], *c; char *gpa = strchr(str, ' '); if ((fP = fopen("names.dat", "r")) == NULL) { printf("%s not opened", "names.dat"); exit(EXIT_FAILURE); } do { c = fgets(str, N ,fP); char *gpa = strchr(str, ' '); *gpa++ = '\0'; printf("%s\t%s\n", str, gpa); } while (c != NULL); ...

3. How can I split a filename into a filename string and extension string?    cboard.cprogramming.com

Actually, when I did this, I wrote one myself. (Though Quzah's suggestion of strrchr is a good one.) Basically, you need to find the last '.'. strrchr() will do that. You don't really want to search forward, should they pass something exotic like I.Am.Special, and end up with ".Am.Special". There's also the issue of them passing a extensionless file that is ...

4. Read a huge line from a file and split at a specific string    forums.devshed.com

You don't indicate if there are any content clues other than the END-REC pattern itself. If not, you read as much as you can at a time, find the END-REC, copy that (everything up through the END-REC) to a destination file, write out the newline, and repeat from there until you're done, reading additional information as necessary. You can't actually insert ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.