i am trying to read a file and save to array

i wrote one and it worked accept it not reading ot line by line, so i wrote another one but i am trying to make it as function
when i make function call i get this error

read.c:32:13: error: invalid operands to binary * (have ‘char *’ and ‘char *’)

the function should take char* so whats the problem ?

my code

#include <stdio.h>

Nstring *readLine(FILE *file)
    char buffer[1000];
char * Nstring ;
char *line ;

    numstring *result = [ numstring  strc:256];

    int chars;
        if(fscanf(file, "%4095[^\n]%n%*c", buffer, &chars) == 1)
            [res = appendFormat:@"%s", buffer];
    } while(chars == 1000);

    return res;
int main (){
char * Nstring ;
char *line ;
FILE *file = fopen("myfile", "r");
// check for NULL
    Nstring *line = readLine(file);

return 0 ;

Recommended Answers

All 7 Replies

It looks like you're mixing standard C and Objective-C. Note that this is the C forum, did you mean to post in the Objective-C forum?

** yes ...i am mixing between them ...i dont know the Objective C ...i am learning how to program with C not Objective C ..but i use what i see on the internet and combine it to make specific code ... so definitely i am mixing between them now !


That's a problem because your code will not compile as C, and if you ask questions in the C forum, the first thing you'll be told is one of the following (depending on how helpful and familiar with Objective-C the person is):

  1. Your code is not C and is wrong.
  2. Your code is Objective-C and you're in the wrong place.

If you want to learn C, learn C, not some bastardization of C and Objective-C that may not compile as either.

it looks like you need another header file.

You need headers like

  1. <math.h>
  2. <stdlib.h>
  3. <curses.h> or if you are using microsoft <conio.h>
  4. <stdfx.h>
  5. <graphics.h>


You need headers like
<curses.h> or if you are using microsoft <conio.h>

If you don't know what you're talking about, please don't pretend that you do. Because those of us that know what we're talking about will see through it easily.

ok ,,, i was just asking ,, i am sorry i will write another one with C not Objective C cuz i dont deal with it ,, i thought it was C

thanks for the information though

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.