C :: Displays Random Symbols As Opposed To 1234
Nov 7, 2014
Code:
#include <stdio.h>#include <string.h>
int main() {
char pin [] = {1,2,3,4};
printf("%s",pin);
getchar();
}
the above code displays random symbols as opposed to 1234
View 2 Replies
ADVERTISEMENT
Jan 19, 2014
I'm experimenting, making a little client/server but when it cout's the buffer, it prints out random symbols.
Server
#include <iostream>
#include <windows.h>
#include <WinSock2.h>
int main() {
char buffer[1024];
WSAData wsa;
[Code] ......
View 9 Replies
View Related
May 3, 2013
I've been currently stuck on a C++ problem. Here's the question:
Write a program that generates one hundred random integers between 0 and 9 and displays the count for each number. (Hint: Use rand()
% 10 to generate a random integer between 0 and 9. Use an array of ten integers, say counts, to store the counts for the number of O's, l 's, . .. , 9's.)
I think I'm pretty close, but I keep on getting "0" for the occurrences (or counts) of each random integer.
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <conio.h>
#include <fstream>
using namespace std;
const int SIZE = 100;
[Code] .....
View 4 Replies
View Related
Oct 15, 2014
If I have an array and all I have is an upper limit on how big the array can get, and if the number of elements that get added can be considerably smaller than this limit, is it always the right choice to declare a pointer and just reallocate extra memory whenever the array grows? For instance, instead of declaring int a[max] I can declare a pointer int *a and than just realloc when I add elements.
View 1 Replies
View Related
Sep 28, 2013
I have the following details
double x= 1.5
double y= -1.5
int m= 20
int n= 4
my question is 5 * x - n / 5 at which what would n / 5 equal to, I think its zero since its integer division? or would the 5 be considered a real number?
View 2 Replies
View Related
Oct 7, 2012
I'm attempting to write a program that displays an array of labels; however, I can't seen to make the labels appear in the form. I've set some of the properties, but still not luck.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
[Code]...
View 4 Replies
View Related
Sep 25, 2014
I was trying to code a program that accepts your first name and then last name and then displays it through another function. I have checked that the assignments are between similar type of variables and pointers, but I don't seem to get it right.
When first input is taken and then second one, the first one's value changes to same as the second. E.G if first name is L and second name is S and after second input both variables, first and sec, become equal to S. Why?
Code:
#include <stdio.h>
#include <stdlib.h>
//FUNCTION PROTOTYPES
char *input(void);
void show(char *f,char *s);
[code]....
View 7 Replies
View Related
Mar 8, 2013
Is it possible to create a function that can both return and display a value. I was trying to make a program that computes and prints terms of the Fibonacci series using a recursive function.
View 3 Replies
View Related
Apr 30, 2013
I'm using Code Blocks but for some reason it doesn't process alt symbols. You know... alt symbols are like this: ☺♫↓☻♪♥↕. Code Blocks says that they're "invalid characters". Is there any attatchments or mods so Code Blocks can process them or will changing the settings?
View 1 Replies
View Related
Jan 10, 2013
I built a C++ static library using WatCom IDE. It compiles without error, but running WLIB on it produces the msg:
Warning! Library contains no external symbols My WatCom compiler host is windows, & target is DOS.
If I convert the Library to an .exe program, by adding a main(), it executes fine, So there seems to be something I'm missing in the IDE settings for building a .lib.
View 2 Replies
View Related
Jan 30, 2012
For example, how to output "Delta" (like a triangle) in C++?
View 13 Replies
View Related
Oct 18, 2014
Having some trouble with an assignment. Here is the prompt. Write a program that reads the telephone.dat file and displays its contents on the console. The program should allow the user to add new entries to the file.
I have saved the file into a resource file within visual studio and I am trying to run the code to where the file will be shown when I run the program. I know that the program is running and the file is there because if i misspell the filename it will give me the error message. I don't know how to make the contents of the file display. Here is what I have so far.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
ifstream inputFile;
[Code]...
View 15 Replies
View Related
Oct 1, 2014
This is just the portion of my program. This program displays Not Found even if the id number is found.
void search(void) {
char ID[10];
int i, found;
cout<<"Enter ID to search: ";
gets(ID);
found=0;
for(i=0;i<top;i++)
[Code] .....
Here's the incorrect output
Enter ID to search: 111
Not found
Name: jude
ID: 111
Semester: 1
Major: IT
I just want to remove the "Not found".
View 1 Replies
View Related
Nov 18, 2014
I'm not sure why Im getting a wrong Sum. of the Columns.
Write a method that returns the sum of all the elements in a specific column in a matrix using the following header:
double sumColumn(const double m[] [SIZE], int rowSize, int columnIndex)
Write a test program that reads a 3-by-4 matrix and displays the sum of each column. here is a sample run:
Enter a 3-by-4 matrix row by row:
1.5 2 3 4
5.5 6 7 8
9.5 1 3 1
Sum of the elements at column 0 is 16.5
Sum of the elements at column 1 is 9.0
Sum of the elements at column 2 is 13.0
Sum of the elements at column 3 is 13.0
#include <iostream>
using namespace std;
const int SIZE = 4;
int rowSize=3;
[Code].....
View 1 Replies
View Related
Jan 1, 2015
I'm making a program that prints a triangle of @ signs given rows (but not columns).
For example, the output with rows = 4 would be:
@@@@
@@@
@@
@
and rows = 3 would be:
@@@
@@
@
However, trying to make this has given me a program that does something similar (but not the same):
for example, with my current program rows = 4 outputs:
@@@@
@@@
@@
@
and rows = 3 gives
@@@
@@
@
It seems that it's just missing a space (and therefore a setw and setfill), but I found 2 problems:
1. The space needs to not apply to the first line.
2. I can't get it to make a space before each row without making a space between each column.
My current code is:
#include <iostream>
#include <iomanip>
using namespace std;
int main ( ) {
int rows;
[Code] ....
I have tried putting in << setws and << setfills of various values but it seems to always apply to between each column as well as at the start of each row- what do I do?
View 4 Replies
View Related
Jun 10, 2013
I need a function to check if the inputted string contains a colon. It has to be in an if loop as the condition.
View 1 Replies
View Related
Aug 6, 2013
how to ask the user to input operating symbols like "+","-","*" and then use it to operate on the numbers. The user should be asked to input the symbols not like this
1.+
2.-
3.*
View 2 Replies
View Related
Sep 11, 2014
I'm working on a program in C++ that is supposed to read in a file, store the content of the file into a 2D array, assign characters to each of the numbers in the array and store in a char array, and print both of these arrays. It's then supposed to go through the initial array and make sure that each number doesn't differ in value from it's neighboring numbers by more than 1, correct these errors by replacing these numbers with the value of the average of their neighbors, assign characters to this corrected array as it did before, and print both arrays.
The character assignments go as follows:
0=blank
1=.
2=,
3=_
4=!
5=+
6=*
7=#
8=$
9=&
I have the code written that opens the file and loads the array, but where to go from there. To me the obvious, although probably not best, way to do the assignments is to go through the array with a for loop and use a series of if statements to check for the value of the number at each index and assign the appropriate symbol.
Here is the code I have so far:
#include <iostream>
#include <fstream>
using namespace std;
int main() {
int size = 100, i, j;
prog >> size;
int **numArray = new int* [size];
[code].....
View 2 Replies
View Related
Oct 6, 2013
The breakpoints I am setting are not caught by the IDE. Any how I can recover that.
I used to know I can delete the sdf file and rebuild. Just to make sure...
View 4 Replies
View Related
Aug 1, 2013
I've read that we can write a program that displays a menu of commands for the user to choose from.We can write some functions that implement these commands, then store pointers to the functions in the array :
Code:
void ( *file_cmd[])(void) = { new_cmd , open_cmd }; // 2 cmd's for simplicity
We can get a similar effect with a switch statement but using an array of function pointers gives us more flexibility since the elements of the array can be changed as the programm is running.
I decided to write an example about this in order to understand better the context, I am facing some problems though :
Code:
#include<stdio.h>
#include<stdlib.h>
typedef void (*p_foo) (int);
void foo(int x);
void foo2(int y);
[Code] .....
The problems are :
Code:
TEST2.c:9: warning: initialization from incompatible pointer type
TEST2.c:9: warning: initialization from incompatible pointer type
TEST2.c:25: error: too few arguments to function "*(arr + (long unsigned int)((long unsigned int)i * 8ul))"
View 14 Replies
View Related
Mar 24, 2013
I'm trying to create a two dimensional array that displays zeroes in a 10 by 10 format. But I don't really know how.I've been playing around and this is what I have so far:
Code:
#include<stdio.h>
int main(void) {
int my_array[10][10]={0};
int i,j;
[code]....
View 6 Replies
View Related
Feb 27, 2013
The assignment is to create a program that displays the median of an array using pointers. Assume the array is already in ascending or descending order.I'm getting errors currently on the bottom two "return median;" statements.The code that I have so far is as follows...
#include <iostream>
using namespace std;
char again;
int getMedian(int*, int);
const int constant = 100;
[code]....
View 3 Replies
View Related
Oct 24, 2014
write a program that computes the factorial of a number and displays it. A factorial of a number (written N!) is defined as N * (N-1) * (N-2) * (N-3) ... *1 In other words, 5! = 5 * 4 * 3 * 2 * 1 = 120 and 3! = 3 * 2 * 1 + 6.
Example of output 15 is 1.30767e+012
Can't get it to display error when user enters a number lower than 2 or higher 60.
// Program to calculate factorial of a number
#include <iostream>
#include <iomanip>
[Code].....
View 13 Replies
View Related
Jan 12, 2015
So I need to make a program that prints a triangle of symbols in a certain direction.
For example: Code: How many rows? 3
@
@@@
@@@@@
How to do that. It's rare that I post without figuring anything out, but I'm just simply not sure. I have a program that prints a triangle in a similar direction, so maybe if I could get some hints as to what to do with that (HINTS, not direct source code) .
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main ( ) {
[Code] .....
View 6 Replies
View Related
Dec 16, 2014
for example having input "12345556asf87" we get "123456asf". I need to do this task with getchar and putchar, and the with strings. My programs aren't working
stream:
char c = 0, c_ = 0;
char flag = 0;
while ((c = getchar()) != '.')
{
[Code]....
View 1 Replies
View Related
Oct 29, 2013
I need to find 2 similar words in one sentence and i need to find how much symbols are between these two words. I can't figure out the algorithm.
For example sentence would be-
This is nice table and nice chair.
Similar words are- nice
Symbols between them are 11 or 8(dont know if space is count as symbol)
int main()
char text[200],*dist;
printf("Enter one sentence
");
gets(text);
Maybe first of all would be
dist=strtok(text, " ,.!?");
while(dist!=0)
{
printf("%s
", dist);
dist=strtok(NULL, " ,.!?");
}
and it wil output each word and maybe then can search for similar words if there would be 2 strings then i would use strstr but i dont know how to do with one string.
View 1 Replies
View Related