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 1093189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:47:34+00:00 2026-05-16T23:47:34+00:00

My instructor said the way to start this is to use the getline() function

  • 0

My instructor said the way to start this is to use the getline() function from out book, then get the numbers from the line, then have those numbers in matrix form, I do not understand why I would use getline?

//eventually this code should take in a square matrix and from 2×2 to 6×6
//the plan is to get it to read in a line, then get the numbers from the line,
//then print out the numbers in a matrix form. That is the goal for today.
//later I will try to get the actual matrix part working

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

//error list for error checking will need later I guess (from my notes)
#define ENDOFFILE -1 
#define TOOMANYNUMS -2
#define LIMIT  256

//functions declared
int get_line(char line[], int);

//main
main(){
char line[255];
int num[6];
printf("Please input numbers %c: ", line);
get_line(line,LIMIT);


}

//functions 
  int get_line(char s[],int lim){
  int c, i;
    for (i=0;i<lim-1 && (c=getchar())!=EOF && c!='\n'; ++i)
  s[i] = c;
if(c=='\n'){
s[i]=c;
  ++i; 
}
s[i]='\0';
return i;
}
  • 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-05-16T23:47:34+00:00Added an answer on May 16, 2026 at 11:47 pm

    The getline(char[], int) function reads characters from the console with getchar() and stores them in the array s[]. The array s[] points at the same memory as the line[] array in the main() function.

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

Sidebar

Related Questions

As title said, I'm trying to figure out how to use javascript and jquery
For PhoneGap Application, as the instruction said, I have replaced the setContentView() line with
I have this code provided by my instructor. I am supposed to fix it
IL doesn't always use callvirt instruction for virtual methods in a case like this:
I wanted to use a script using instant messaging and found this. The instruction
On 27 February 2003, Apple employee Christopher Nebel said he'd like to straighten out
This is the driver code provided by my instructor, It isn't meant to be
hi i'm watching a c++ tutorial and instructor includes the libraries like this #
I got this from a berkley cs data structures webcast: class A { void
This is actually the program my instructor had provided with us to work with,

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.