Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8948985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:07:58+00:00 2026-06-15T13:07:58+00:00

I do not write in C often and am having some trouble. For starters

  • 0

I do not write in C often and am having some trouble. For starters I think I am sure I am putting lines I am reading in from textfiles into a 2D array correctly. Also I am having a problem when I try and put the line into the array. I get a warning that the assignment makes integer from pointer without a cast. I want it to be a char and I think thats why I am getting a Seg Fault since it is bigger than the size i allocated. I have included my code below. I bet this is a stupid mistake, I havent used C in a while thanks!

#include <stdio.h>
FILE *fid;
char line[70];
char dna[66800][70];

main() {
    int counter = 0; 
    fid = fopen("dna.fna","r");
    while(fgets(line, sizeof(line), fid) != NULL){
        //fputs ( line, stdout ); 
    dna[counter][0] = line;   //Getting a Seg Fault here     
    counter++;
    }

    fclose(fid); 

} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:07:59+00:00Added an answer on June 15, 2026 at 1:07 pm

    The assignment in this case should actually be a copy, like this:

    strncpy(dna[counter], line, sizeof(line));
    

    The warning you are getting is caused by line being decayed into a pointer and trying to assign that to a char.

    You also have to be sure that counter will never exceed 66800.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a Greasemonkey script for Facebook and having some trouble with
Say that a method only reads data from a database and does not write
I'm using GAE[JAVA] to do some image processing. GAE will not allow write file
I've begun diving into Django again and I'm having trouble finding the parallel to
Why not write the anonymous function content only instead of the anonymous function AND
My question is not clear at title [i can not write it exactly] e.g
Why does eclipse break with the error Could not write file: M:\workspaces\eclipse\project.project. M:\workspaces\eclipse\project.project (Access
I'm interesting in gathering usage metrics for an application that I did not write
How can I fix the following error? error: cs0016 could not write to output
I'm searching for a robust lightweight grid for ASP.NET MVC. I'd rather not write

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.