Thanks for all the help! It solved my errors :):)
Type: Posts; User: tidemann
Thanks for all the help! It solved my errors :):)
Thanks a lot! Didn't know that it could be done that simple.
int d;
for(d=0;d<strlen(cur);d++) {
if(cur[d] == '&')
printf("you wrote & sign\n");
}
I need to loop through a char array containing a line read by fgets and check for the '&' character. I thought that fgetc or getc might do the trick, but it seems that they can only recieve a FILE...
Its only a snippet of a bigger system, pasting the whole code here would be too much... the code-snippet shouldnt compile... Thanks for the quick replies though. Strncpy did the trick! Thanks yxunomei
I'm trying to copy a recieved char-array (cur) into cur2. Cur is a line read by fgets from user-input.
I need a copy because cur is later divided into words, but cur2 should hold the entire line....
I solved the problem. I just had to re-write most of the copying... If anybodys interested I'll post the finished code at demand
Since ant is working with the concurrent object in the list I thought that it should be a char* since it will contain text . The fgets-example I posted above won't work if its declared as anything...
It should be a pointer to a struct(ure). I'm a newbie when it comes to creating single-lists in structures.
First I thought that...
if (fgets(ant,LENGTH ,file) == NULL) {
...
Ops! ant_line should be ant (edited now).. just a typo. If I use malloc(strlen(ant->line) + 1) i get the following error:
"request for member 'line' in something not a structure or union"
Ok! Thanks for the help. I've been working a couple of hours more now and figured some things out. A simplified code piece:
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000
#define...
I need to get a C program to read a text-file (with aprox. 4 lines) to a linked list. and print it out.
A simple method of doing this:
char c[10];
FILE *file;
file = fopen(argv[1],...